c语言三个数字排序,c语言用scanf读三个数字,然后按照升序排列.

满意答案

dcebd7a0de6265b6ccae5ead692f1eab.png

Sr.ALong

2013.11.29

dcebd7a0de6265b6ccae5ead692f1eab.png

采纳率:48%    等级:11

已帮助:8005人

刚学几节课就写那么复杂的东西,真是佩服.看看下面这个吧,比较简单.

#include "stdio.h"

main()

{

int a,b,c,t;

printf("please input a,b and c:\n");

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;}

if(b>c)

{t=b,b=c,c=t;}

printf("%4d%4d%4d",a,b,c);

}

-------------------------------------------

这样改吧:

#include

#define INPUT_ONE 9

#define INPUT_TWO 10

#define INPUT_THREE 11

int increaseNum (int a, int b, int c);

int main (int argc, char * argv[]) {

int a=INPUT_ONE;

int b=INPUT_TWO;

int c=INPUT_THREE;

printf ("Enter three numbers\n");

scanf ("%d%d%d", &a,&b,&c);

increaseNum(a,b,c);

}

int increaseNum (int a, int b, int c)

{ int t;

if (a>b){t=a, a=b, b=t;}

if (a>c){t=a, a=c, c=t;}

if (b>c){t=b, b=c, c=t;}

printf ("%d\n%d\n%d\n",a,b,c);

}

00分享举报

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值