利用c语言编写一个简单的小学生测验系统,功能要求如下。
发布网友
发布时间:2022-04-24 17:37
我来回答
共3个回答
热心网友
时间:2023-10-27 02:05
#include "stdio.h"
#include "iostream"
#include "windows.h"
#define MAX 1000
char problems[MAX][100];
int answers[MAX];
bool flag[MAX] = {false};
int score;
int n;
void init()
{
score = 0;
FILE *fp = fopen("D:\\题库.txt","r");//这里修改路径
fscanf(fp,"%d",&n);
for(int i = 0;i < n;i++)
fscanf(fp,"%s%d",problems[i],&answers[i]);
fclose(fp);
}
void solve(int i,int k)
{
int ans = 0;
printf("第%d题(现在总分是%d分):\n",i,score);
for(int j = 0;j < 3;j++)
{
printf("%s=",problems[k]);
scanf("%d",&ans);
if(ans == answers[k])
{
if(j == 0)
score += 10;
else if(j == 1)
score += 7;
else
score += 5;
if(i != 10)
printf("正确!,下一题......\n");
return;
}
printf("- -,错误......\n");
}
}
void start()
{
int count = 0,t;
while(count != 10)
{
t = rand()%n;
if(flag[t])
continue;
flag[t] = true;
solve(count+1,t);
count++;
}
if(score < 60)
printf("TRY AGAIN\n");
else if(score < 70)
printf("PASS\n");
else if(score < 80)
printf("OK\n");
else if(score < 90)
printf("GOOD\n");
else
printf("SMART\n");
}
int main()
{
srand(GetTickCount());
init();
start();
system("pause");
}
题库.txt
11
1+2 3
1+3 4
1+4 5
1+5 6
7-1 6
7-2 5
7-3 4
11-3 8
11-4 7
11-5 6
11-6 5
热心网友
时间:2023-10-27 02:06
纯粹抄是没有用的,你先试着做一下,要有自己的思路,不懂的地方在来问。
热心网友
时间:2023-10-27 02:06
谁闲的蛋疼