2019-05-29
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int m = 10;
double random()
{
return (double)rand() / RAND_MAX;
}
int random(int m)
{
return (int)(random() * (m - 1) + 0.5);
}
int main()
{
srand(time(NULL));
int right = 0;
for(int i = 0; i < 10; i++)
{
int x, y;
for(;;)
{
x = random(m) + 1;
y = random(m) + 1;
if(x != y) break;
}
printf("%d + %d = ", x, y);
int ans;
scanf("%d", &ans);
if(ans == (x + y))
{
right++;
printf("正确");
}
else
printf("错误");
}
printf("总分:%d 错误%d道", right * 10, 10 - right);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int m = 10;
double random()
{
return (double)rand() / RAND_MAX;
}
int random(int m)
{
return (int)(random() * (m - 1) + 0.5);
}
int main()
{
srand(time(NULL));
int right = 0;
for(int i = 0; i < 10; i++)
{
int x, y;
for(;;)
{
x = random(m) + 1;
y = random(m) + 1;
if(x != y) break;
}
printf("%d + %d = ", x, y);
int ans;
scanf("%d", &ans);
if(ans == (x + y))
{
right++;
printf("正确");
}
else
printf("错误");
}
printf("总分:%d 错误%d道", right * 10, 10 - right);
return 0;
}