C语言大型作业教小学生算数.docx

上传人:b****4 文档编号:3740259 上传时间:2022-11-25 格式:DOCX 页数:17 大小:175.53KB
下载 相关 举报
C语言大型作业教小学生算数.docx_第1页
第1页 / 共17页
C语言大型作业教小学生算数.docx_第2页
第2页 / 共17页
C语言大型作业教小学生算数.docx_第3页
第3页 / 共17页
C语言大型作业教小学生算数.docx_第4页
第4页 / 共17页
C语言大型作业教小学生算数.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

C语言大型作业教小学生算数.docx

《C语言大型作业教小学生算数.docx》由会员分享,可在线阅读,更多相关《C语言大型作业教小学生算数.docx(17页珍藏版)》请在冰豆网上搜索。

C语言大型作业教小学生算数.docx

C语言大型作业教小学生算数

《C语言工程训练》

 

课程设计题目:

教小学生算数

学生学号:

学生姓名:

指导教师:

一、需求分析

通过此系统实现以下功能

做个位数,十位数的加,减,乘和除,减法不能得负数,除法要除尽,屏幕上随机出现两个数,提示小学生给出答案,答错了要提示重新输入,直到答对为止。

要统计给分,且累计,够一定分数后可进级,即从个位进到十位。

同样,也可降级。

1)加法功能:

用PLUS函数实现加法算数,答对输入的题量后可晋级,难度有所增加,结果错误后提示错误并且重新输入。

2)减法功能:

用sub函数实现减法算数,并且结果不为负数,答对输入的题量后可晋级,难度有所增加,结果错误后提示错误并且重新输入。

3)乘法功能:

用mul函数实现乘法算数,答对输入的题量后可晋级,难度有所增加,结果错误后提示错误并且重新输入。

4)除法功能:

用div函数实现除法功能,并且生成的除法算数要除尽,答对输入的题量后可晋级,难度有所增加,结果错误后提示错误并且重新输入。

 

二、总体设计

1)组成框图

 

2)流程图

三、详细设计

#include

#include

#include

voidmenu()

{

printf("********************************************************************************");

printf("^_^_^_^_^_^_^_^_^_^_^_^小朋友,欢迎你们来学习小学算术_^_^_^_^_^_^_^_^_^_^_^_^_^_");

printf("");

printf("1.加法");

printf("2.减法");

printf("3.乘法");

printf("4.除法");

printf("0.退出");

printf("");

printf("快选择你要学习的内容吧!

");

printf("");

printf("^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_^_");

printf("********************************************************************************");

}

voidplus1()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第一关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

printf("%d",m=rand()%10);

printf("+");

printf("%d",n=rand()%10);

printf("=");

total=m+n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第一关!

\n");

}

voidplus2()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第二关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%10;

n=rand()%100;

}while(n<10);

printf("%d",m);

printf("+");

printf("%d",n);

printf("=");

total=m+n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}}

printf("恭喜你通过了第二关!

\n");

}

voidplus3()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第三关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%100;

}while(m<10&&n<10);

printf("%d",m);

printf("+");

printf("%d",n);

printf("=");

total=m+n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第三关!

\n");

}

voidsub1()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第一关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%10;

n=rand()%10;

}while(m<=n);

printf("%d",m);

printf("-");

printf("%d",n);

printf("=");

total=m-n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第一关!

\n");

}

voidsub2()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第二关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%10;

}while(m<10);

printf("%d",m);

printf("-");

printf("%d",n);

printf("=");

total=m-n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第二关!

\n");

}

voidsub3()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第三关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%100;

}while(m<=n||m<10||n<10);

printf("%d",m);

printf("-");

printf("%d",n);

printf("=");

total=m-n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第三关!

\n");

}

voidplus()

{

inti;

plus1();

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

plus2();

else

return;

i=NULL;

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

plus3();

else

return;

}

voidsub()

{

inti;

sub1();

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

sub2();

else

return;

i=NULL;

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

sub3();

else

return;

}

voidmul1()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第一关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

printf("%d",m=rand()%10);

printf("*");

printf("%d",n=rand()%10);

printf("=");

total=m*n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第一关!

\n");

}

voidmul2()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第二关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%10;

}while(m<10);

printf("%d",m);

printf("*");

printf("%d",n);

printf("=");

total=m*n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第二关!

\n");

}

voidmul()

{

inti;

mul1();

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

mul2();

}

voiddiv1()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第一关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%10;

n=rand()%10;

}while(n==0||m%n!

=0);

printf("%d",m);

printf("/");

printf("%d",n);

printf("=");

total=m/n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第一关!

\n");

}

voiddiv2()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第二关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%10;

}while(n==0||m<10||m%n!

=0);

printf("%d",m);

printf("/");

printf("%d",n);

printf("=");

total=m/n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}

printf("恭喜你通过了第二关!

\n");

}

voiddiv3()

{

intcount=0,m,n,s,total,k;

printf("欢迎进入第三关!

\n");

printf("请设定题目数量:

");

scanf("%d",&k);

while(count

do{

m=rand()%100;

n=rand()%100;

}while(n==0||m<10||n<10||m%n!

=0);

printf("%d",m);

printf("/");

printf("%d",n);

printf("=");

total=m/n;

loopa:

scanf("%d",&s);

if(s==total)

{printf("恭喜你,答对了!

\n");count++;}

else

{printf("回答错误,请重新回答!

\n");gotoloopa;}

}printf("恭喜你通过了第三关!

\n");

}

voiddiv()

{

inti;

div1();

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

div2();

else

return;

i=NULL;

printf("是否继续挑战?

Y

(1)/N(0):

");

scanf("%d",&i);

if(i==1)

div3();

else

return;}

main()

{

voidmenu();

intk;

do{

menu();

printf("请选择:

");

scanf("%d",&k);

switch(k)

{

case1:

plus();break;

case2:

sub();break;

case3:

mul();break;

case4:

div();break;

case0:

break;

}printf("\n");

}while(k!

=0);

printf("\n");

return0;}

 

四、测试结果

1)主程序界面

2)加法运算

 

3)减法运算

4)乘法运算

 

5)除法运算

五、设计体会

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 小升初

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1