c语言 10以内加法,求助 给小学生出题,自己选加减乘除 做10题 10以内的数 然后统计分...
該樓層疑似違規(guī)已被系統(tǒng)折疊?隱藏此樓查看此樓
#include?
#include?
#include?
void?Menu(void)
{
printf("1,加法?2,減法?3,乘法?4,除法?5,退出\n");
printf("請(qǐng)選擇題目類(lèi)型:");
}
int?Plus(void)
{
int?a,?b;
a?=?rand()?%?10?+?1;
b?=?rand()?%?10?+?1;
printf("%-2d?+?%-2d?=?",?a,?b);
return?a?+?b;
}
int?Sub(void)
{
int?a,?b;
a?=?rand()?%?10?+?1;
b?=?rand()?%?10?+?1;
printf("%-2d?-?%-2d?=?",?a,?b);
return?a?-?b;
}
int?Mult(void)
{
int?a,?b;
a?=?rand()?%?10?+?1;
b?=?rand()?%?10?+?1;
printf("%-2d?*?%-2d?=?",?a,?b);
return?a?*?b;
}
int?Div(void)
{
int?a,?b;
while(a?%?b?!=?0)
{
a?=?rand()?%?10?+?1;
b?=?rand()?%?10?+?1;
}
printf("%-2d?/?%-2d?=?",?a,?b);
return?a?/?b;
}
int?Subject(int?type)
{
switch(type)
{
case?1:?return?Plus();
case?2:?return?Sub();
case?3:?return?Mult();
case?4:?return?Div();
}
}
void?Do(int?type)
{
int?count?=?0,?score?=?0,?key,?answer;
while(count?
{
key?=?Subject(type);
scanf("%d",?&answer);
if(key?==?answer)
score?+=?10;
count++;
}
printf("%d\n",?score);
}
int?main(void)
{
int??type,?score;
while(1)
{
Menu();
scanf("%d",?&type);
if(type?==?5)?return?0;
Do(type);
system("pause");
system("cls");
}
}
總結(jié)
以上是生活随笔為你收集整理的c语言 10以内加法,求助 给小学生出题,自己选加减乘除 做10题 10以内的数 然后统计分...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c语言流程图char,求救!各位大神,用
- 下一篇: c语言怎么解析midi文件,c – 无法