C语言 猜数字程序

[复制链接]
查看11 | 回复2 | 2010-10-5 10:21:10 | 显示全部楼层 |阅读模式
#include
#include
#include
int main()
{
char ch;
int i,a,c;
printf("猜数字游戏\n\n");
{srand(time(NULL));
i=(rand()%10);
printf("请输入数字\n\n");
do
{
scanf("%d",&a);
if(i>a)printf("小了\n");
if(i#include #include int main(){ char ch;int i,a,c;printf("猜数字游戏\n\n"); {srand(time(NULL));i=(rand()%10);printf("请输入数字\n\n");
回复

使用道具 举报

千问 | 2010-10-5 10:21:10 | 显示全部楼层
你先拿5来测试看符合不符合你的要求。测试好了再把i=5;去掉。#include #include #include int main(){ char ch;int i,a,c;printf("Welcome to guess the number\n\n^_^
回复

使用道具 举报

千问 | 2010-10-5 10:21:10 | 显示全部楼层
do{// ...}while((ch=getchar())!='n');赋值号的优先级低于不等判断,所以要加括号。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行