C语言设计 帮忙修改一下

来源:百度知道 编辑:UC知道 时间:2024/05/29 10:44:47
随机出10道加法 回答对就出Right 错就wrong 最后统分
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
int f(int x,int y)
{
int z;
if(z=x+y) return 1;
else return 0;
}
void main()
{
int f(int x,int y);
int a,b,c,i,j=0;
char l;
srand((unsigned)time(NULL));
k:
clrscr();
for(i=1;i<11;i++)
{
a=rand()%10+1;
b=rand()%10+1;

printf("\n[%2d] :%2d + %2d=",i,a,b);
scanf("%d",&c);c=f(a,b);
if(c==1)
{
printf("\n Right!\n");
j++;
}
if(c==0)

printf("\n Wrong!\n");

}
printf("\nYour score is %d !\n",j*10);
printf("\nDo you want again?<Y/N>\n");

#include "stdio.h"
#include "time.h"
#include "stdlib.h"
int f(int x,int y,int z)
{

if(z==(x+y)) return 1;
else return 0;
}
void main()
{
int f(int x,int y,int z);
int a,b,c,i,k,j=0;
char l;
srand((unsigned)time(NULL));
k:
clrscr();
for(i=1;i<11;i++)
{
a=rand()%10+1;
b=rand()%10+1;

printf("\n[%2d] :%2d + %2d=",i,a,b);
scanf("%d",&c);k=f(a,b,c);
if(k==1)
{
printf("\n Right!\n");
j++;
}
if(k==0)

printf("\n Wrong!\n");

}
printf("\nYour score is %d !\n",j*10);
printf("\nDo you want again?<Y/N>\n");
getchar();
l=getchar();
if(l=='y'||l=='Y') goto k;
clrscr();
printf("\n B Y E !\n");