to:卧龙孔明
----------------
呵呵,代码一大堆看着不太清楚,帮着排了下版。不过有个疑问:为什么我加上头文件<stdio.h>之后反而编译错误了呢?
程序代码:
long time(long*);
int getch(),rand(),srand(int),scanf(char*,...),printf(char*,...);
int su,da[6]={0};
void f0()
{
system("cls");
su=0;printf("\t\t小学生CAI系统\n\n");
{
int i;
for(i=0;i<50;printf("="),++i);
printf("\n");
}
printf("\t\ta.加法运算\n\t\tb.减法运算\n\t\tc.乘法运算\n\t\td.除法运算\n\t\te.综合运算\n\t\tf.四则混合运算\n\t\tg.退出系统\n");
{
int i;
for(i=0;i<50;printf("="),++i);
printf("\n");
}
printf("\n请选择 => ");
}
void f1(int x,int z)
{
int t;
switch(x)
{
case 1:while(t=rand()%200,z+t>1e3);
printf("+%d",t);su+=t;
break;
case 2:while(t=rand()%200,z-t<0);
printf("-%d",t);
su-=t;
break;
case 3:while(t=rand()%200,z*t>1e3);
printf("*%d",t);su*=t;
break;
case 4:while(t=rand()%200+1,z%t!=0);
printf("/%d",t);
su/=t;
break;
}
}
void f2()
{
int c=1,n;
char t;
while(scanf("%c",&t),t!='\n');
while(c<3)
{
n=0;
printf("第%d次尝试,请输入你的答案 => ",c);
while(t=getch(),t!=13)
{
if(t==27) return;
if(t<='9' && t>='0')
printf("%c",t),n*=10,n+=t-'0';
}
if(n==su) printf("\n答案正确\n"),c=5;
else printf("\n答案错误\n"),++c;
}
if(c==3)printf("\n正确答案: %d\n",su);
system("pause");
}
main()
{
int i,j,k;
char t;
srand(time(0));
f0();
while(scanf("%c",&t)!=-1)
{
if(t<='f'&&t>='a')system("cls"),printf("已做%d道该项练习\n%d",da[t-'a'],su=rand()%200+1);
switch(t)
{
case'a':
case'b':
case'c':
case'd': f1(t-'a'+1,su);
break;
case'e': for(i=rand()%4+1,j=0;
j<=1;i--,j++)f1(i,su);
break;
case'f': f1(i=rand()%2+3,su);
f1(7-i,su);
f1(i=rand()%2+1,su);
f1(3-i,su);break;
case'g': return 0;
default: f0();
}
if(t<='f' && t>='a')
printf("=\n"),f2(),da[t-'a']++,f0();
}
}
PS:学习一下~
[[it] 本帖最后由 广陵绝唱 于 2008-11-7 09:05 编辑 [/it]]