程序随机给出A~Z之间的字母.让用户猜测这个字母#include "stdio.h"#include "time.h"#include "stdlib.h"main(){char guess,m;int cout=0;srand((unsigned)time(NULL));m=rand()%26+'A';do{printf("猜A~Z的字符\n");scanf("%d",&gues

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 21:06:08
程序随机给出A~Z之间的字母.让用户猜测这个字母#include"stdio.h"#include"time.h"#include"stdlib.h"main(){charguess,m;intc

程序随机给出A~Z之间的字母.让用户猜测这个字母#include "stdio.h"#include "time.h"#include "stdlib.h"main(){char guess,m;int cout=0;srand((unsigned)time(NULL));m=rand()%26+'A';do{printf("猜A~Z的字符\n");scanf("%d",&gues
程序随机给出A~Z之间的字母.让用户猜测这个字母
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
main()
{
char guess,m;
int cout=0;
srand((unsigned)time(NULL));
m=rand()%26+'A';


do
{
printf("猜A~Z的字符\n");
scanf("%d",&guess);
if(guess'Z')
printf("输的数没A~Z的在范围内");
if(guess>m)
printf("猜大了");
if(guess

程序随机给出A~Z之间的字母.让用户猜测这个字母#include "stdio.h"#include "time.h"#include "stdlib.h"main(){char guess,m;int cout=0;srand((unsigned)time(NULL));m=rand()%26+'A';do{printf("猜A~Z的字符\n");scanf("%d",&gues
这样写就可以了
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
void main()
{
char guess,m;
int count=0;
srand((unsigned)time(NULL));
m=rand()%26+'A';
do
{
printf("猜A~Z的字符\n");
fflush(stdin);
scanf("%c",&guess);
if(guess < 'A'||guess > 'Z')
{
printf("输的数没A~Z的在范围内\n");
continue;
}
if(guess > m)
{
printf("猜大了");
continue;
}
if(guess < m)
{
printf("猜xiao了");
continue;
}
if(guess == m)
{
printf("恩恩");
}
}while(++count,guess != m);
printf("你共猜了%d次才猜对,正确的为%c",count,m);
return;
}