# 小学数学编程题

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
char m,n;
int a,b,c,d,e,f,g,t=0,i;
int begin,end;
begin = time(NULL);
end = time(NULL);
printf(“请输入用户ID：”);
scanf("%c%c%d",&m,&n,&a);
if((m>=‘A’&&m<=‘Z’)&&(n>=‘A’&&n<=‘Z’)&&(a>=1000&&a<=9999)){
printf(“请选择以下三种选择：\n”) ;
printf("(1)开始测试\n");
printf("(2)检查分数\n");
printf("(3)退出\n");
}
else printf(“用户名格式错误！无法登录！”);
scanf("%d",&g);
if(1<=g&&g<=3){
switch(g){
case 1:
for(i=0;i<10;i++){
a = rand()%100+1;
b = rand()%100+1;
e = rand()%4+1;
switch(e){
case 1:d=a+b;printf("%d+%d=",a,b);scanf("%d",&f);break;
case 2:d=a-b;printf("%d-%d=",a,b);scanf("%d",&f);break;
case 3:d=ab;printf("%d%d=",a,b);scanf("%d",&f);break;
case 4:d=a/b;printf("%d/%d=",a,b);scanf("%d",&f);break;
}
if(d==f){
printf(“回答正确！\n”);
t=t+1;
}else{
printf(“回答错误！答案是：%d\n”,d);
}
printf(“总分=%d\n”,t*10);
end = time(NULL);
printf(“time = %d\n”,end-begin);
system(“pause”);
}break;
case 2:
break;
case 3:
printf(“成功退出！”);
break;
}
}
}

#include
#include
using namespace std;
int main()
{
FILE *fp;
fp=fopen(“2.txt”,“w”);
int n;
cin>>n;
cout<<n<<endl;
fprintf(fp,"%d",n);
fclose(fp);
return 0;
}

12-20
05-27 5218

09-19 87
06-12 7820
11-02 1623
11-30 3266
07-31 1627
03-19 85