输入三个数,然后从大到小输出
2013-03-30 00:29
190 查看
#include <stdio.h>
#include <stdlib.h>
void Descending(int &a,int &b,int &c){
int temp=0;
if(a<b){
temp=a;a=b;b=temp;//促使a>=b
}
if(b<c){
temp=c;c=b;//促使temp>=c
if(a>=temp) b=temp;
else{
b=a;a=temp;//注意,不能写成a=temp;b=a;
}
}
}
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
Descending(a,b,c);
printf("%d %d %d\n",a,b,c);
system("pause");
return 0;
}
#include <stdlib.h>
void Descending(int &a,int &b,int &c){
int temp=0;
if(a<b){
temp=a;a=b;b=temp;//促使a>=b
}
if(b<c){
temp=c;c=b;//促使temp>=c
if(a>=temp) b=temp;
else{
b=a;a=temp;//注意,不能写成a=temp;b=a;
}
}
}
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
Descending(a,b,c);
printf("%d %d %d\n",a,b,c);
system("pause");
return 0;
}
相关文章推荐
- 输入a,b,c三个整数,按由大到小顺序输出。(用3个指针变量指向3个整形变量,然后用swap函数来实现互换3个整型变量的值)
- c语言:从键盘输入BOY三个字符,然后把它们输出到屏幕。
- python 输入三个变量,然后按小到大输出(解析)
- 输入三个整数,将他们排序然后输出中间那个数
- 【c语言】从键盘输入BOY三个字符,然后把它们输出到屏幕
- c语言:从键盘输入BOY三个字符,然后把它们输出到屏幕。
- 从键盘上输入三个整数,分别赋给整型变量a,b,c. 然后将输入的整数按照从小到大的顺序放在a,b,c中, 并输出三个变量的值。
- 算法:输入三个数,然后输出最大的数
- 输入a,b,c三个整数,按由大到小顺序输出。(用3个指针变量指向3个整形变量,然后用swap函数来实现互换3个整型变量的值)
- 二分查找 先输入数据库的个数再一一录入数据 然后输入要查找对象的个数再一一录入对象 最后依次输出对象是否在数据库中的结论
- 5、输入三角形的三个边长a,b,c,输出面积s,要求保留一位小数位,总位数7位。
- jQuery中实现:当文本框输入值,验证值不符合规格,然后是文本框输出原来的值的方法
- 输入成绩进行判断,然后输出ABCDE
- 从控制台输入用户名和密码, 然后 判断输入的用户名是否是@“Frank”, 密码 是否是 @“lanou”, 如果用户名和密码都正确,则输出登录成功, 否则输出登录失败.
- 在主函数中输入10个等长的字符串。用另一个函数对它们排序,然后主函数输出10个已经排好的字符串
- 3.2 设计一个程序,要求用户输入 5 个字符,然后将这 5 个字符按相反的顺序显示出 来。例如,假设输入 abcde,则输出为 edcba
- 【程序5】题目:输入三个整数x,y,z,请把这三个数由小到大输出。(多种方法)
- 输入10个整数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换。写三个函数; ①输入10个数;②进行处理;③输出10个数。
- 键盘输入三个数,输出其中最大的数
- 输入三个数a,b,c,要示按由小到大的顺序输出