鱼C论坛

 找回密码
 立即注册
查看: 4950|回复: 3

求解为什么编译后运行无法输入数字

[复制链接]
发表于 2013-5-1 20:58:07 | 显示全部楼层 |阅读模式
5鱼币
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <process.h>

void main(void)
{
    int answer[4],guess=0, a=0, b, times=0, i, j;
    for(i=0; i<=3; i++)
    {
        randomize();
        answer[i] = rand()%10;
        for(j=0; j<i;j++)
        {
            while(answer[i]==answer[j])
            {
                answer[i]=rand()%10;
                j=-1;
            }
        }
    }
    printf("please guess\n");
    while(a!=4);
    {
        a=0;
        b=0;
        times++;
        do{
            printf("%d     ",times);
            scanf("%d",&guess);
            if(guess==0)
                exit(0);
        }
        while(guess<0||guess>9999);
        for(i=3;i>-1;i--)
        {
            for(j=0;j<4;j++)
            {
                if((int)(guess/pow(10,i))==answer[j])
                {
                    if(i+j==3) a=a+1;
                    else b=b+1;
                }
            }
            guess=guess-(int)(guess/pow(10,i))*pow(10,i);
        }
        printf("      %dA%dB\n", a, b);
    }
}

最佳答案

查看完整内容

后面不应该有 “;”分号。
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2013-5-1 20:58:08 | 显示全部楼层
  1. while(a!=4);
复制代码
后面不应该有 “;”分号。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2013-5-2 16:56:28 | 显示全部楼层
楼上说的是对的
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-5-2 18:01:42 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

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

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-29 20:59

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表