-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path56年级运算题3.cpp
99 lines (88 loc) · 1.27 KB
/
56年级运算题3.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
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{ int flag = 0;
int j,xh;
srand(time(0));
scanf("%d",&xh);
for(j=0;j<xh;j++)
{
int i;
int num1 = rand()%4;
int num3 = rand()%3+2;
char s[4] = {'+','-','*','/'};
double shu[num3];
char ys[num3];
int l = 0;
int k = 0;
for(i=0;i<num3;i++)
{
int num = rand()%4;
double num2 = (double)rand()/RAND_MAX*(10000-0)+0;
shu[l] = num2;
l += 1;
printf("%f",num2);
if(i!=num3-1)
{
ys[k] = s[num];
k += 1;
printf("%c",s[num]);
}
if(i==num3-1)
printf("=");
}
printf("\n");
int js;
int m = 0;
for(i=0;i<k;i++)
{
switch(ys[i])
{
case '*':
shu[i+1] = shu[i+1]*shu[i];
ys[i]=']';
break;
case '/':
shu[i+1] = shu[i]+shu[i+1];
ys[i]=']';
break;
}
}
for(i=0;i<k;i++)
{
if(ys[i]==']')
{
shu[i] = 0;
}
}
int shu1[5];
char ys1[4];
for(i=0;i<k;i++)
{
switch(ys[i])
{
case ']':
shu[i+1] = shu[i] + shu[i+1];
break;
case '+':
shu[i+1] = shu[i] + shu[i+1];
break;
case '-':
shu[i+1] = shu[i] - shu[i+1];
break;
}
}
double sl;
double p;
int qs;
qs = (int)(shu[num3-1]*100+0.5);
p = qs /100.0;
scanf("%f",&sl);
if(p != qs)
{flag++;
}
//printf("%.2f\n ",shu[num3-1]);
}
return 0;
}