| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 105 人关注过本帖
标题:atm机问题,输入任何数,没有输出
只看楼主 加入收藏
qmsb2580
Rank: 2
等 级:论坛游民
帖 子:50
专家分:20
注 册:2018-10-20
结帖率:100%
  已结贴   问题点数:20  回复次数:4   
atm机问题,输入任何数,没有输出
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<string.h>
void gotoxy(int x,int y);
void code();
void face();//界面函数声明
void realcode_face();

void gotoxy(int x,int y)
{
    COORD coord;
    coord.X=x;
    coord.Y=y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}    //光标定位函数


void code()
{
    long int code;
     gotoxy(12,5);
    scanf("%d",&code);
   
   
   
   
///////////////////////////////////////////////////////////   
    if(code!=123456)
    {   
        gotoxy(11,6);
        printf("对不起code错误");
    }
   
    else
    {
        gotoxy(11,6);
    printf("code right!");
    system("cls");
    realcode_face();
    }
/////////////////////////////////////////////////////////   
}


void face()  //界面函数
{
printf("*********************************************\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                 输入code                  *\n");
printf("*                                           *\n");//gotoxy(12,5);
printf("*     code:                                *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*********************************************\n");
}

void realcode_face()
{

   int choose;
printf("*********************************************\n");
printf("*                                           *\n");
printf("*            1.取款                         *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*            2.存款                         *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*  请输入:                                 *\n");
printf("*                                           *\n");
printf("*                                           *\n");
printf("*********************************************\n");
   //gotoxy();         //这个我
   scanf("%d",&choose);
   if((choose!=1)||(choose!=2))
   printf("请输入正确的标号!"); //就是这里,我不管输入什么数,没有任何输出,而且程序编译的时候没有报错!!!!!!!!!!!!!
   

}

int main()
{   
    face();
    code();
    gotoxy(1,15);
    return 0;
   
}
6 天前 21:21
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:版主
威 望:373
帖 子:12992
专家分:50319
注 册:2012-10-18
  得分:20 
*********************************************
*                                           *
*            1.取款                         *
*                                           *
*                                           *
*                                           *
*                                           *
*                                           *
*            2.存款                         *
*                                           *
*                                           *
*                                           *
*  请输入:                                 *
*                                           *
*                                           *
*请按任意键继续. . . ************************
1
请输入正确的标号!

这不是有提示信息吗

DO IT YOURSELF !
5 天前 10:47
qmsb2580
Rank: 2
等 级:论坛游民
帖 子:50
专家分:20
注 册:2018-10-20
  得分:0 
回复 2楼 wp231957
我的目的是输入不是标号意外的数,程序就输出(请输入正确的标号)
但是,这段代码不管输入任何数,输出都是这句话
4 天前 01:39
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:版主
威 望:373
帖 子:12992
专家分:50319
注 册:2012-10-18
  得分:0 
程序代码:

fflush(stdin);
   scanf("%d",&choose);
   if(choose==1)   printf("我要取款!"); //


当然了,大虾说用fflush(stdin);来吸收回车符 不准确 据说标准答案是用getchar 还是啥来着  忘了

DO IT YOURSELF !
4 天前 08:51
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:版主
威 望:373
帖 子:12992
专家分:50319
注 册:2012-10-18
  得分:0 
*            2.存款                         *
*                                           *
*                                           *
*                                           *
*  请输入:                                 *
*                                           *
*                                           *
*请按任意键继续. . . ************************
1
我要取款!





DO IT YOURSELF !
4 天前 08:51







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043577 second(s), 8 queries.
Copyright©2004-2019, BCCN.NET, All Rights Reserved