C语言设计一个运算10道问答题的程序

要求是回答一个问题就自动换为另一个问题
Testing System
List 10 math questions ━ Input answer for every question ━ Present correct answer if user’s answer not correct ━ Give the final score.

#include <stdio.h>
void check(double correct_answer[],double answer[],char question[10][100])
{
int i,score=0;
for(i=0;i<10;i++)
if(answer[i]!=correct_answer[i])
printf("第%d题“%s”:答案错误,正确答案应为:%.1Lf\n",i+1,question[i],correct_answer[i]);
else
score+=10;
printf("你的总分为:%d\n",score);
}
void main()
{
char question[10][100]={"2x+3=0,求x?","x*x-4x+4=0,求x?","11*11=?","直角边为根号7的等腰三角形面积是?","sin30=?","对x从2积分到3为?","5!=?","六个人排队,组合有几种?","二进制100转化为十进制是?","1+1=?"};
double correct_answer[10]={-1.5,2,121,3.5,0.5,2.5,120,720,4,2};
double answer[10]={0};
int i;
puts("开始答题:");
for(i=0;i<10;i++)
{
printf("第%d题:\t",i+1);
puts(question[i]);
scanf("%lf",&answer[i]);
}
check(correct_answer,answer,question);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-06-01
把10道题存在一个链表中
#define LEN//每个问题最大长度。
typedef struct problemlib{
bool pstatus;//问题状态TRUE回答了,FLASE未回答.
char problem[LEN];
struct problemlib *next;
}* plib;
然后,存上问题,用一个一个循环,当回答一个问题后,将状态置TRUE。
回答下一个问题
第2个回答  2010-06-01
这个只需要设置一个默认字符提示回答结束就好了,比如按“回车”即答题完毕!在程序内增加一个循环,判断接收的字符时否"\n";如果是就清屏,然后再打印新的问题到屏幕上即可
第3个回答  2010-06-04
#include<stdio.h>
#include<conio.h>

void main()
{
char que[10][30] =
{
"1 + 1 = 2 吗 ?(Y|N)", //题目可自行设计
"3 + 1 = 2 吗 ?",
"你过得快乐吗 ?",
"0 + 1 = 2 吗 ?",
"你现在12岁吗 ?",
"0 + 1 = 2 吗 ?",
" mm 吃饭没有 ?",
"0 + 1 = 2 吗 ?",
"0 + 1 = 2 吗 ?",
"0 + 1 = 2 吗 ?",
};
int i;
char v;

for (i = 0; i < 10; i++)
{
puts(que[i]);
putchar(v = getch());
putchar('\n');
}
}
第4个回答  2010-06-01
这没什么算法要求啊,我都不知道要怎么答了,反正你就按顺序写就是了.
相似回答
大家正在搜