这道题小D不思其解!请来帮帮!
这道题小D不思其解!请来帮帮!
[此贴子已经被作者于2005-6-12 18:59:51编辑过]
我是菜鸟啦!~ 菜鸟用菜办法。。。 //main.cpp #include<iostream.h> void f1(int a); void f2(int a); void f3(int a); void f4(int a); void main(){ cout<<"**********************************************"<<endl; cout<<"** **"<<endl; cout<<"** 小学生算术练习系统 1.0V **"<<endl; cout<<"** **"<<endl; cout<<"**********************************************"<<endl; cout<<"请选择运算类型:(1-5)"<<endl; cout<<"1.加法。"<<endl; cout<<"2.减法。"<<endl; cout<<"3.乘法。"<<endl; cout<<"4.除法。"<<endl; cout<<"5.退出。"<<endl;
int a; cin>>a; switch(a){ case 1:f1(a);break; case 2:f2(a);break; case 3:f3(a);break; case 4:f4(a);break; case 5:break; //1.cpp #include<iostream.h> #include<stdlib.h> #include<time.h> #include<string.h> void f1(int a){ srand(time(0)); int k,x,y,z; double r=0.0,w=0.0; char b='y'; n cout<<endl; cout<<"请输入序号:(1-4)"<<endl; cout<<"1.简单"<<endl; cout<<"2.中等"<<endl; cout<<"3.高级"<<endl; cout<<"4.退出"<<endl; cin>>k; switch(k){ case 1: while(b=='y'||b=='Y') {x=rand()%10; y=rand()%10; cout<<x<<'+'<<y<<'='; cin>>z; if(z==x+y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} goto no;
} case 2: while(b=='y'||b=='Y') {x=rand()%50; y=rand()%50; cout<<x<<'+'<<y<<'='; cin>>z; if(z==x+y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} } case 3: while(b=='y'||b=='Y') {x=rand()%100; y=rand()%100; cout<<x<<'+'<<y<<'='; cin>>z; if(z==x+y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} case 4:break; default:{ cout<<"输入有误,重新输入!"<<endl; goto no;} } } } //2.cpp #include<iostream.h> #include<stdlib.h> #include<time.h> #include<string.h> void f2(int a){ srand(time(0)); int k,x,y,z; double r=0.0,w=0.0; char b='y'; n cout<<endl; cout<<"请输入序号:(1-4)"<<endl; cout<<"1.简单"<<endl; cout<<"2.中等"<<endl; cout<<"3.高级"<<endl; cout<<"4.退出"<<endl; cin>>k; switch(k){ case 1: while(b=='y'||b=='Y') {x=rand()%10; y=rand()%10; cout<<x<<'-'<<y<<'='; cin>>z; if(z==x-y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;}
} case 2: while(b=='y'||b=='Y') {x=rand()%50; y=rand()%50; cout<<x<<'-'<<y<<'='; cin>>z; if(z==x-y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} } case 3: while(b=='y'||b=='Y') {x=rand()%100; y=rand()%100; cout<<x<<'-'<<y<<'='; cin>>z; if(z==x-y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} case 4:break; default:{ cout<<"输入有误,重新输入!"<<endl; goto no;} } } } //3.cpp #include<iostream.h> #include<stdlib.h> #include<time.h> #include<string.h> void f3(int a){ srand(time(0)); int k,x,y,z; double r=0.0,w=0.0; char b='y'; n cout<<endl; cout<<"请输入序号:(1-4)"<<endl; cout<<"1.简单"<<endl; cout<<"2.中等"<<endl; cout<<"3.高级"<<endl; cout<<"4.退出"<<endl; cin>>k; switch(k){ case 1: while(b=='y'||b=='Y') {x=rand()%10; y=rand()%10; cout<<x<<'*'<<y<<'='; cin>>z; if(z==x*y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;}
} case 2: while(b=='y'||b=='Y') {x=rand()%50; y=rand()%50; cout<<x<<'*'<<y<<'='; cin>>z; if(z==x*y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} } case 3: while(b=='y'||b=='Y') {x=rand()%100; y=rand()%100; cout<<x<<'*'<<y<<'='; cin>>z; if(z==x*y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} case 4:break; default:{ cout<<"输入有误,重新输入!"<<endl; goto no;} } } } //4.cpp #include<iostream.h> #include<stdlib.h> #include<time.h> #include<string.h> void f4(int a){ srand(time(0)); int k,x,y,z; double r=0.0,w=0.0; char b='y'; n cout<<endl; cout<<"请输入序号:(1-4)"<<endl; cout<<"1.简单"<<endl; cout<<"2.中等"<<endl; cout<<"3.高级"<<endl; cout<<"4.退出"<<endl; cin>>k; switch(k){ case 1: while(b=='y'||b=='Y') {x=rand()%10; y=rand()%10; cout<<x<<'/'<<y<<'='; cin>>z; if(z==x/y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;}
} case 2: while(b=='y'||b=='Y') {x=rand()%50; y=rand()%50; cout<<x<<'/'<<y<<'='; cin>>z; if(z==x/y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} } case 3: while(b=='y'||b=='Y') {x=rand()%100; y=rand()%100; cout<<x<<'/'<<y<<'='; cin>>z; if(z==x/y){cout<<"Right"<<endl;r++;} else {cout<<"Wrong"<<endl;w++;} cout<<"继续练习?(Y/N)"; cin>>b; if(b!='y'){cout<<"正确率是:"<<double(r/(r+w))*100<<'%'<<endl;goto no;} case 4:break; default:{ cout<<"输入有误,重新输入!"<<endl; goto no;} } } }
[此贴子已经被作者于2005-6-12 19:11:51编辑过]