-
Notifications
You must be signed in to change notification settings - Fork 0
/
【工程】十以内加减法辅助教学程序
129 lines (121 loc) · 2.76 KB
/
【工程】十以内加减法辅助教学程序
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 <stdio.h>
#include <stdlib.h>
#include <time.h>
void Jiafa();
void Jianfa();
int main()
{
int n;
printf("10以内加减法辅助教学程序\n");
printf("**********************************\n");
printf("**********************************\n");
printf("** **\n");
printf("** 1 加法练习 **\n");
printf("** 2 减法练习 **\n");
printf("** 3 程序说明 **\n");
printf("** 4 退出程序 **\n");
printf("** **\n");
printf("**********************************\n");
printf("**********************************\n");
printf("输入菜单项前的数字,选择功能,如数字超过菜单中的范围将显示0\n");
scanf("%d",&n);
switch(n)
{
case 1:
system("cls");
Jiafa();
break;
case 2:
system("cls");
Jianfa();
break;
case 3:
system("cls");
printf("该程序的作用为计算10以内加减法");
break;
case 4:
exit(0);
default:
printf("选择了功能0");
}
}
void Jiafa()
{
int a,b,c,m,counter1=1;
static int flag=0;
float counter2=0;
snack:do{
srand(time(NULL));
a=rand()%10;
b=rand()%10;
c=a+b;
}
while(c>10);
while(counter1<=5)
{
counter1++;
printf("%d+%d=",a,b);
scanf("%d",&m);
if(m==c)
{
counter2++;
flag=1;
goto snack;
}
else
{
do{
counter1++;
printf("%d+%d=",a,b);
scanf("%d",&m);
if(m==c)
counter2++;
}while(m!=c&&counter1<=5);
}
}
if(flag!=1)
{
printf("试答的次数太多,正确答案:%d+%d=%d\n",a,b,c);
}
printf("正确率为:%.1f",counter2/5);
}
void Jianfa()
{
int a,b,c,m,counter1=1;
static int flag=0;
float counter2=0;
snack:do{
srand(time(NULL));
a=rand()%10;
b=rand()%10;
c=a-b;
}
while(c<=0);
while(counter1<=5)
{
counter1++;
printf("%d-%d=",a,b);
scanf("%d",&m);
if(m==c)
{
flag=1;
counter2++;
goto snack;
}
else
{
do{
counter1++;
printf("%d-%d=",a,b);
scanf("%d",&m);
if(m==c)
counter2++;
}while(m!=c&&counter1<5);
}
}
if(flag!=1)
{
printf("试答的次数太多,正确答案:%d-%d=%d",a,b,c);
}
printf("正确率为:%.1f",counter2/5);
}