-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path日文.cpp
85 lines (85 loc) · 1.57 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
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
#include<stdio.h>
#include<stdlib.h>
void Japanese()
{
system("CLS");
int a,i,op,count;
int x,y,m,n,b,d,z,result,tem;
printf("生成の題目数を入力して下さい:\n");
scanf("%d",&a); //生成题目数
for(i=0;i<a;i++)
{
x=rand()%100;//随机生成数
y=rand()%100;
while(1) //m(分子)不为0
{
m=rand()%100;
if(m!=0)
break;
}
while(1) //n(分子)不为0
{
n=rand()%100;
if(n!=0)
break;
}
op=rand()%8; //随机生成符号(整数运算与分数运算)
switch(op)
{
case 0: //整数加法运算
printf("%d+%d=",x,y);
result=x+y;
break;
case 1: //整数减法运算
if(x<y) //不能为负数
{
tem=x;
x=y;
y=tem;
}
printf("%d-%d=",x,y);
result=x-y;
break;
case 2: //整数乘法运算
printf("%d*%d=",x,y);
result=x*y;
break;
case 3: //整数除法运算
printf("%d/%d=",x,m);
result=x/m;
break;
case 4: //分数加法运算
b=x*n+y*m;
d=m*n;
printf("%d/%d+%d/%d=",x,m,y,n);
result=b/d;
break;
case 5: //分数减法运算
b=x*n-y*m;
d=m*n;
printf("%d/%d-%d/%d=",x,m,y,n);
result=b/d;
break;
case 6: //分数乘法运算
b=x*y;
d=m*n;
printf("(%d/%d)*(%d/%d)=",x,m,y,n);
result=b/d;
break;
case 7: //分数除法运算
b=x*n;
d=m*y;
printf("(%d/%d)/(%d/%d)=",x,m,y,n);
result=b/d;
break;
}
scanf("%f",&z);
if(z==result){ //判断正误
printf("正しい\n");
count++;
}
else
printf("誤り\n");
}
printf("総題目数%d,ごとに1分ずつある,総得点%d\n",a,count);
}