-
Notifications
You must be signed in to change notification settings - Fork 0
/
小学生.cpp
31 lines (29 loc) · 1.17 KB
/
小学生.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
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int n,i,j,number[4],answer;
char symbol[4]={'+','-','*','/'},symbolnow[4];
scanf("%d",&n);
srand(time(NULL));
for(i=1;i<=n;i++)
{
for(j=0;j<4;j++)
{
number[j]=rand()%11;
symbolnow[j]=symbol[rand()%4];
}
switch(rand()%5)
{
case 0:printf("%d%c%d%c%d%c%d=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);break;
case 1:printf("(%d%c%d)%c%d%c%d=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);break;
case 2:printf("%d%c(%d%c%d%)%c%d=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);break;
case 3:printf("%d%c%d%c(%d%c%d)=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);break;
case 4:printf("(%d%c%d%c%d)%c%d=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);break;
case 5:printf("%d%c(%d%c%d%c%d)=?\n",number[0],symbolnow[0],number[1],symbolnow[1],number[2],symbolnow[2],number[3],symbolnow[3]);
}
scanf("%d",&answer);
}
return 0;
}