KYLY康 发表于 2014-5-2 18:55:40

为什么输入三个数之后 enter不能直接得到结果,还必须再次输入字符再次enter才得到结

#include<stdio.h>
void main()
{int a,b,c,max,min,ch,sh;
printf ("plesae input three number: \n");
scanf("%d%d%d\n",&a,&b,&c);
ch=a>b?a:b;
printf("max=%d",ch>c?ch:c);
sh=a<b?a:b;
printf("min=%d",sh<c?sh:c);          
}

HHR 发表于 2014-5-2 18:55:41

scanf("%d%d%d\n",&a,&b,&c); 改为 scanf("%d%d%d",&a,&b,&c);

牡丹花下死做鬼 发表于 2014-5-2 21:00:49

#include<stdio.h>
void main()//建议框架不要这么写
{
        int a,b,c,max,min,ch,sh;
        printf ("plesae input three number: \n");
        //scanf("%d%d%d\n",&a,&b,&c);
        scanf("%d%d%d",&a,&b,&c);
        ch=a>b?a:b;//建议不要使用三目运算符
        printf("max=%d",ch>c?ch:c);
        sh=a<b?a:b;
        printf("min=%d",sh<c?sh:c);         
}

KYLY康 发表于 2014-5-2 21:57:11

牡丹花下死做鬼 发表于 2014-5-2 21:00 static/image/common/back.gif


谢谢了 朋友 额 上边的【朋友回答的早了点就设置了最佳答案,还望谅解 谢谢

KYLY康 发表于 2014-5-2 21:58:07

HHR 发表于 2014-5-2 18:55 static/image/common/back.gif
scanf("%d%d%d\n",&a,&b,&c); 改为 scanf("%d%d%d",&a,&b,&c);

谢谢了。。。
页: [1]
查看完整版本: 为什么输入三个数之后 enter不能直接得到结果,还必须再次输入字符再次enter才得到结