今天高中同学叫我帮他写期末任务书的代码,写了一个关于试卷组卷系统的简单代码,这个函数主要是为了给C语言重修的兄弟应付的,所以只写了核心代码,交互界面以及美化都交给他自己,中间使用了goto语句,算是一个小瑕疵。
从构思到写完用了不到1小时,算是一个满意的过程。
![](https://img-blog.csdn.net/20180715191910674?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0ZldWRfTA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
#include
#include
#include
#include
void main()
{
int a = 0;
int b = 0;
int mode = 0;
int c = 0;
int result = 0;
int score = 0;
int i = 0;
srand((unsigned)time(NULL));//调用随机
for (i = 0; i < 10; i++)
{
int g = 1;
there:
a = rand() % 50;
b = rand() % 50;
mode = rand() % 1;
switch (mode)
{
case 0:
result = a + b;
if (result > 50)
goto there;//检验result的值
else
break;
case 1:
result = a - b;
if (result < 0)
goto there;
else
break;
}
for (g = 1; g =90)//分等级
{
printf("SMART");
}
else if (score >= 80)
{
printf("GOOD");
}
else if (score >= 70)
{
printf("OK");
}
else if (score >= 60)
{
printf("PASS");
}
else if (score < 60)
{
printf("TRY AGAIN");
}
getchar();
getchar();
getchar();
}
|