回复 4楼 wp231957
我改了一下,但实在写不下去了,有的变量类型不同,但我又不想再重新定义变量,太复杂了,简直是推倒重来。程序代码:
#include<stdio.h> #include<math.h> void subject(int a); main() { int a; printf("请选择章节(2-7):"); scanf("%d",&a); printf("习题%d:\n",a); subject(a); } void subject(int a) { switch(a) { case 1: printf("输入有误!\n"); break; case 2: { float x,y,z; x=y=z=2.5; printf("2.1\n"); printf("These vluses are:\n"); printf("x=%.2f\n",x); printf("y=%.2f\n",y); printf("z=%.2f\n",z); break; } case 3: { int a=12,b=3,m=32,n=81,p,q,c,d,e,f,g; double x=18.5,y=4.6; float capital,deposit; printf("3.1.1\n");//3.1.1 printf("%f\n\n",(float)(a*b)/2); printf("3.1.2\n");//3.1.2 p=m++; q=--n; printf("%d%d\n",p,q); printf("%d%d\n\n",m,n); printf("3.2\n");//3.2 printf("请输入一个三位数:"); scanf("%d",&a); if ("a>=0") b=a; else b=-a; c=b%10; d=(int)b/10; e=d%10; f=(int)d/10; g=f+e*10+c*100; printf("它的逆序数是:%d\n\n",g); printf("3.3\n");//3.3 printf("请输入本金:"); scanf("%f",&capital); printf("请输入年份:"); scanf("%d",&n); deposit=capital*pow(n,1.0225); printf("本利之和为%f\n\n",deposit); printf("3.4");//3.4 printf("请输入a:"); scanf("%f } break; } }