啊哈磊_编程从这里起步

标题: 从键盘任意读入3个整数,如何从中找出最小的一个? [打印本页]

作者: 我和谐勒个去    时间: 2014-5-12 23:12
标题: 从键盘任意读入3个整数,如何从中找出最小的一个?


作者: rosynirvana    时间: 2014-5-13 00:23
书上的习题?
题解区全都有的

http://bbs.ahalei.com/forum-60-1.html
作者: fish    时间: 2014-5-13 12:29
#include <stdio.h>
#include <stdlib.h>
int main()
{
        int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b)
                if(a<=c)
                        printf("%d",a);
        else
                        printf("%d",c);
    else
                if(b<=c)
                        printf("%d",b);
        else
                        printf("d",c);
       
        system("pause");
        return 0;
}

作者: 杨艺晨    时间: 2014-5-13 15:06
用FOR循环,将这三个数两两比较。应该是对的吧,我学PASCAL是这样的的。
作者: StarX    时间: 2014-5-16 17:48
还可以这样:int main(){
    int a,b,c,t;
    printf("input three numbers:");
    scanf("%d %d %d",&a,&b,&c);
    if(a<b)
    {
        t=a;
        a=b;
        b=t;
    }
    if(a<c)
    {
        t=a;
        a=c;
        c=t;
    }
    printf("\n%d is the biggest.\n",a);
}

作者: 1935515130    时间: 2014-5-16 19:40
杨艺晨 发表于 2014-5-13 15:06
用FOR循环,将这三个数两两比较。应该是对的吧,我学PASCAL是这样的的。
你的pascal很厉害吗?如果是,那就请教教我——9月要比赛了!!!{:soso_e101:}

作者: 杨艺晨    时间: 2014-6-26 18:32
推荐你一本书吧,《Free Pascal语言与基础算法》(科学技术文献出版社),我在淘宝上买的,可详细了!自己看看就可以。
作者: 瑞比兔    时间: 2014-7-13 10:45
#include <stdio.h>
#include <stdlib.h>
int main()
{        int a,b,c,d;
        scanf("%d %d %d",&a,&b,&c);
    if (a<b)  d=a;
    else d=b;
        if (d>c)  d=c;
   
    printf("%d",d);
   
        system("pause");
        return 0;
}
作者: 1991jiangjun1    时间: 2014-7-18 13:46
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
        int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b) d=a;
    else d=b;
    if(c<d) d=c;
    printf("%d",d);
        system("pause");
        return 0;
}[/mw_shl_code]
作者: 230467747    时间: 2014-8-2 13:19
#include <stdio.h>
#include <stdlib.h>
int main()
{
        int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b)
                if(a<=c)
                        printf("%d",a);
        else
                        printf("%d",c);
    else
                if(b<=c)
                        printf("%d",b);
        else
                        printf("d",c);
        
        system("pause");
        return 0;
}




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2