小学生算数系统代码,求大神帮忙看一下,给个注释
#include<stdio.h>#include<windows.h>
#include<time.h>
#include <stdlib.h>
void gotoxy(int x,int y);
double goadd(void);
char mygetchar(void);
int main(void)
{
char i;
double pa;
printf("选择练习项目:\n");
printf("1)练习加法 2)练习减法\n");
printf("1)练习乘法 2)练习除法\n");
printf("5)退出系统\n");
while(i=mygetchar())
{
if(i>'0'&&i<'6')
break;
printf("输入错误!请重新输入:");
}
switch(i)
{
case '1' : system("cls");pa=goadd();break;
case '2' : break;
}
printf("您的正确率为:%.2lf%%",pa*100);
getchar();
return 0;
}
double goadd(void)
{
int a[5],b[5],i,m=0,n=0,x,y=0;
double p;
char ch,ch2;
srand((unsigned)time(NULL));
do
{ system("cls");
printf("选择范围:\n");
printf("a)0-10 b)0-20\n");
printf("c)0-50 d)0-100\n");
ch=mygetchar();
while(ch<'a'||ch>'d')
{
printf("输入错误!请重新输入:");
y++;
ch=mygetchar();
}
if(ch=='a')
{
for(i=0;i<5;++i)
{
a[i]=rand()%11;
b[i]=rand()%11;
printf("%2d+%2d=\n",a[i],b[i]);
}
}
if(ch=='b')
{
for(i=0;i<5;++i)
{
a[i]=rand()%21;
b[i]=rand()%21;
printf("%2d+%2d=\n",a[i],b[i]);
}
}
if(ch=='c')
{
for(i=0;i<5;++i)
{
a[i]=rand()%51;
b[i]=rand()%51;
printf("%2d+%2d=\n",a[i],b[i]);
}
}
if(ch=='d')
{
for(i=0;i<5;++i)
{
a[i]=rand()%101;
b[i]=rand()%101;
printf("%2d+%2d=\n",a[i],b[i]);
}
}
for(i=0;i<5;++i)
{
m++;
gotoxy(7,i+y+4);
scanf_s("%d",&x);
if(x==a[i]+b[i])
{
gotoxy(15,i+y+4);
printf("√");
n++;
}
else
{
gotoxy(15,i+y+4);
printf("×");
}
}
while(getchar()!='\n')
continue;
printf("\n是否继续?(Y/N)\n");
ch2=mygetchar();
}while(ch2!='N'&&ch2!='n');
system("cls");
p=(1.0*n)/m;
gotoxy(26,12);
return p;
}
void gotoxy(int x, int y)
{
COORD coord = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
char mygetchar(void)
{
char ch;
ch=getchar();
while(getchar()!='\n')
continue;
return ch;
}