-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path新需求grade1_2.cpp
126 lines (126 loc) · 2.35 KB
/
新需求grade1_2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include<bits/stdc++.h>
using namespace std;
int flag=0;
int grade1_2()
{
int number;
srand(time(NULL));
int i,a,b,c,d,op,result,num;
char s;
int ans,input;
cin>>number;
for(i=0;i<number;i++)
{
a=rand()%101;
b=rand()%101;
c=rand()%101;
d=rand()%101;
op=rand()%16;
switch(op){
case 0:
cout<<a<<"+"<<b<<"="<<endl;
result=a+b;
cin>>ans;
if(ans!=result)flag++;
break;
case 1:
cout<<a<<"-"<<b<<"="<<endl;
result=a-b;
cin>>ans;
if(ans!=result)flag++;
break;
case 2:
cout<<a<<"+"<<b<<"+"<<c<<"="<<endl;
result=a+b+c;
cin>>ans;
if(ans!=result)flag++;
break;
case 3:
cout<<a<<"+"<<b<<"-"<<c<<"="<<endl;
result=a+b-c;
cin>>ans;
if(ans!=result)flag++;
break;
case 4:
cout<<a<<"-"<<b<<"-"<<c<<"="<<endl;
result=a-b-c;
cin>>ans;
if(ans!=result)flag++;
break;
case 5:
cout<<a<<"-("<<b<<"-"<<c<<")"<<"="<<endl;
result=a-(b-c);
cin>>ans;
if(ans!=result)flag++;
break;
case 6:
cout<<a<<"-"<<b<<"+"<<c<<"="<<endl;
result=a-b+c;
cin>>ans;
if(ans!=result)flag++;
break;
case 7:
cout<<a<<"-("<<b<<"+"<<c<<")"<<"="<<endl;
result=a-(b+c);
cin>>ans;
if(ans!=result)flag++;
break;
case 8:
cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<endl;
result=a+b+c+d;
cin>>ans;
if(ans!=result)flag++;
break;
case 9:
cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<endl;
result=a+b+c-d;
cin>>ans;
if(ans!=result)flag++;
break;
case 10:
cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<endl;
result=a+b-c-d;
cin>>ans;
if(ans!=result)flag++;
break;
case 11:
cout<<a<<"+"<<b<<"-("<<c<<"-"<<d<<")"<<"="<<endl;
result=a+b-(c-d);
cin>>ans;
if(ans!=result)flag++;
break;
case 12:
cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<endl;
result=a-b-c-d;
cin>>ans;
if(ans!=result)flag++;
break;
case 13:
cout<<a<<"-"<<b<<"-("<<c<<"-"<<d<<")"<<"="<<endl;
result=a-b-(c-d);
cin>>ans;
if(ans!=result)flag++;
break;
case 14:
cout<<a<<"-("<<b<<"-"<<c<<"-"<<d<<")"<<"="<<endl;
result=a-(b-c-d);
cin>>ans;
if(ans!=result)flag++;
break;
case 15:
cout<<a<<"-("<<b<<"-"<<c<<")"<<"-"<<d<<"="<<endl;
result=a-(b-c)-d;
cin>>ans;
if(ans!=result)flag++;
break;}
}
return flag ;
}
int main()
{
grade1_2();
if(flag==0)
cout<<"结束!全部正确,太棒了!"<<endl;
else
cout<<"结束!错了" <<flag <<"题哦" <<endl;
}