c语言设计人机猜字游戏:1,用gucess1函数完成人猜电脑想的100以内的证数;2.用gucess2函数完成有电脑想
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
#define N 10
typedef struct _ti {
int a, b;
int op;
int result;
int input;
int rw;
}ti;
ti timu[N];
int fen;
int flag;
int mulu()
{
int s;
while(1) {
printf("\t\t欢迎进入super考试系统\n\n");
printf("1)随机出题\t\t\t\t");
printf("2)开始考试\n");
printf("3)试卷评分\t\t\t\t");
printf("4)显示批改的试卷\n");
printf("5)退出系统\n\n");
printf("请做出选择:");
scanf("%d", &s);
while(getchar()() != '\n');
if(s < 1 || s > 5)
printf("选择有误!请重新输入.\n");
else
break;
}
return s;
}
void chuti()
{
int i, f;
printf("确认随机出%d道题吗?(y确认):", N);
if(getchar()() != 'y')
return;
for(i = 0, f = 1; i < N; f ? i++ : 0) {
timu[i].a = rand() % 100+1;
timu[i].b = rand() % 100+1;
timu[i].op = rand() % 4;
if(timu[i].b == 0 && timu[i].op == 3) {
f = 0;
continue;
}
else
f = 1;
switch(timu[i].op) {
case 0: timu[i].result = timu[i].a + timu[i].b;break;
case 1: timu[i].result = timu[i].a - timu[i].b;break;
case 2: timu[i].result = timu[i].a * timu[i].b;break;
case 3: timu[i].result = timu[i].a / timu[i].b;break;
}
}
printf("出题完毕!\n");
flag = 1;
}