
c++课程设计,各位大虾有空的话帮忙做下,小弟急用!!!谢谢各位了
小学算术测试程序1操作界面美观简洁。2测试小学生对10以内两个正数加,减,乘法运算的能力。3能根据用户输入确定出题数。4随机出题,运算数必须是10以内的正整数,运算符可以...
小学算术测试程序
1 操作界面美观简洁。
2 测试小学生对10以内两个正数加,减,乘法运算的能力。
3 能根据用户输入确定出题数。
4 随机出题,运算数必须是10以内的正整数,运算符可以是加减乘。
5 判断解答是否正确,如果答案错误允许学生重做,在界面上给出提示。
6 累计并显示题数.正确问答次数和错误次数。
7 统计正确率(百分制),并给出相应提示(比如:90分以上输出“Very good!”) 展开
1 操作界面美观简洁。
2 测试小学生对10以内两个正数加,减,乘法运算的能力。
3 能根据用户输入确定出题数。
4 随机出题,运算数必须是10以内的正整数,运算符可以是加减乘。
5 判断解答是否正确,如果答案错误允许学生重做,在界面上给出提示。
6 累计并显示题数.正确问答次数和错误次数。
7 统计正确率(百分制),并给出相应提示(比如:90分以上输出“Very good!”) 展开
3个回答
展开全部
修改了下,改正几个bug,增加四则运算支持。
不会出现除不尽的情况。
============================
WinTC1.91+WinXP调试成功
VC6+WinXP调试成功
P.S. 用C语言写的,拿去糊弄老师足够了。有一部分代码需要你自己改,比如输出"verygood"之类的,相信学过一点C/C++的话,这点小改动不难的吧。另外,要是老师非要C++版本,你就加上iostream.h,然后把printf,scanf之类的改成cout,cin。
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <stdlib.h>
#include <time.h>
int menu()
{
int choice;
printf("1. 开始练习\n");
printf("2. 输入练习数量\n");
printf("3. 退出\n");
printf("请选择(1或2或3):");
scanf("%d",&choice);
return choice;
}
int test( int count )
{
int i,ix,iy,iz,it,right = 0;
int op;
char opCh[4] = { '+', '-', '*', '/' };
system("cls");
printf("开始答题,共%3d道:\n\n",count);
if( count<1 || count>20 )
{
printf("题目数没有录入或者录入错误,请重新录入。\n");
return 0;
}
srand( (unsigned)time(0) );
for( i=0; i<count; i++ )
{
do
{
ix = 1+rand()%9; iy = 1+rand()%9;
if(ix<iy) { it=ix; ix=iy; iy=it; }
op = rand()%4;
} while( op==3 && ix%iy!=0 );
printf("%3d) %d%c%d=",i,ix,opCh[op],iy);
scanf("%d",&iz);
if( (op==0&&iz!=ix+iy) || (op==1&&iz!=ix-iy) || (op==2&&iz!=ix*iy) || (op==3&&iz!=ix/iy) )
printf(" 很可惜你答错了~\n");
else {
printf(" 恭喜你答对了!\n");
right++;
}
}
printf("\n%3d道题目答完,正确率%.2f%%按任意键返回。", count, (float)right/count*100);
return right;
}
void main()
{
int tag = 1, count = 0;
while(tag)
{
system("cls");
switch(menu())
{
case 1: test(count); getch(); break;
case 2:
printf("请输入题数(10~20):");
scanf("%d",&count);
if( count<10 || count>20 )
{ count=0; printf("输入错误。按任意键返回。\n"); }
else
printf("输入成功。按任意键返回。\n");
getch();
break;
case 3: tag=0; printf("\n谢谢使用,再见!\n\n"); getch(); break;
default: break;
}
}
}
不会出现除不尽的情况。
============================
WinTC1.91+WinXP调试成功
VC6+WinXP调试成功
P.S. 用C语言写的,拿去糊弄老师足够了。有一部分代码需要你自己改,比如输出"verygood"之类的,相信学过一点C/C++的话,这点小改动不难的吧。另外,要是老师非要C++版本,你就加上iostream.h,然后把printf,scanf之类的改成cout,cin。
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <stdlib.h>
#include <time.h>
int menu()
{
int choice;
printf("1. 开始练习\n");
printf("2. 输入练习数量\n");
printf("3. 退出\n");
printf("请选择(1或2或3):");
scanf("%d",&choice);
return choice;
}
int test( int count )
{
int i,ix,iy,iz,it,right = 0;
int op;
char opCh[4] = { '+', '-', '*', '/' };
system("cls");
printf("开始答题,共%3d道:\n\n",count);
if( count<1 || count>20 )
{
printf("题目数没有录入或者录入错误,请重新录入。\n");
return 0;
}
srand( (unsigned)time(0) );
for( i=0; i<count; i++ )
{
do
{
ix = 1+rand()%9; iy = 1+rand()%9;
if(ix<iy) { it=ix; ix=iy; iy=it; }
op = rand()%4;
} while( op==3 && ix%iy!=0 );
printf("%3d) %d%c%d=",i,ix,opCh[op],iy);
scanf("%d",&iz);
if( (op==0&&iz!=ix+iy) || (op==1&&iz!=ix-iy) || (op==2&&iz!=ix*iy) || (op==3&&iz!=ix/iy) )
printf(" 很可惜你答错了~\n");
else {
printf(" 恭喜你答对了!\n");
right++;
}
}
printf("\n%3d道题目答完,正确率%.2f%%按任意键返回。", count, (float)right/count*100);
return right;
}
void main()
{
int tag = 1, count = 0;
while(tag)
{
system("cls");
switch(menu())
{
case 1: test(count); getch(); break;
case 2:
printf("请输入题数(10~20):");
scanf("%d",&count);
if( count<10 || count>20 )
{ count=0; printf("输入错误。按任意键返回。\n"); }
else
printf("输入成功。按任意键返回。\n");
getch();
break;
case 3: tag=0; printf("\n谢谢使用,再见!\n\n"); getch(); break;
default: break;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询