主题:人民币求助 选择题源代码
xiaoxiaoniao666
[专家分:0] 发布于 2011-12-22 15:31:00
需要完整的代码。10个选择题,答对恭喜,答错提示正确答案。题目我自己添加。
沙发
tuo2000912 [专家分:0] 发布于 2012-03-02 14:03:00
#include<stdio.h>
#include<conio.h>
int main(int argc,const char *argv)
{
int i;
int a1,b,c,d;
int q1[10]={23,57,46,19,74,88,35,1,67,90};
int q2[10]={98,64,23,34,45,56,78,89,1,12};
char* ans[10]={A,C,D,C,B,B,A,D,B,A};
char k;
int a[10][4]={{121,111,131,120},{111,131,121,120},{59,79,68,69},
{43,63,53,52},{109,119,129,118},{134,144,154,143},
{113,103,114,93},{80,100,89,90},{58,68,78,67},{102,92,112,101};
printf("%s","welcome!");
printf("\n开始吗?");
while(scanf("%c",i)==1)
{
if(i=='n' || i=='N') break;
if(i=='y' || i=='Y')
{
for(i=0; i<10; i++)
{
printf("\n");
a1=a[i][0]; b=a[i][1]; c=a[i][2]; d=a[i][3];
printf(" %d+%d=?\n",q1[i],q2[i]);
printf("A. %d B. %d C. %d D. %d\n",a1,b,c,d);
printf("please select the answer\n");
scanf("%s",k);
if(k==ans[i]) printf("congratulations"); else printf("error!\n the answer is %c",ans[i]);
}
}
getch();
return 0;
}
小学生加法算数程序