41.三个数从小到大排序

描述

现在要写一个程序,实现给三个数排序的功能

输入
输入三个正整数
输出
给输入的三个正整数排序
样例输入
20 7 33
样例输出
7 20 33

 1 #include<stdio.h>
 2 int main( ) {
 3     int a, b, c, t;
 4     scanf("%d%d%d", &a, &b, &c);
 5     if(a > b) {t = a; a = b; b = t;}
 6     if(a > c) {t = a; a = c; c = t;}
 7     if(b > c) {t = b; b = c; c = t;}
 8     printf("%d %d %d\n",a, b, c);
 9     return 0;
10 }

时间: 2024-08-02 03:26:40

41.三个数从小到大排序的相关文章

三个数从小到大排序—南阳acm

描述: 现在要写一个程序,实现给三个数排序的功能 输入 输入三个正整数 输出 给输入的三个正整数排序 样例输入 20 7 33 样例输出 7 20 33 解题思路是先找出最大和最小的数,再找出中间数,并分步输出,下面是代码 #include<stdio.h>  main() {   int a,b,c,m,n;    scanf("%d%d%d",&a,&b,&c);     m=a>b?a:b;m=m>c?m:c;//找出最大值    

三个数从小到大排序

描述 现在要写一个程序,实现给三个数排序的功能 输入 输入三个正整数 输出 给输入的三个正整数排序 样例输入 20 7 33 样例输出 7 20 33 1 #include <stdio.h> 2 3 int main(){ 4 int a; 5 int b; 6 int c; 7 int temp; 8 9 scanf("%d%d%d",&a,&b,&c); 10 11 if(a>b){ 12 temp=a; 13 a=b; 14 b=tem

nyoj 41-三个数从小到大排序(STL --&gt; sort(a, a+n) 升序)

41-三个数从小到大排序 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:31 submit:44 题目描述: 现在要写一个程序,实现给三个数排序的功能 输入描述: 输入三个正整数 输出描述: 给输入的三个正整数排序 样例输入: 复制 20 7 33 样例输出: 7 20 33 分析: 直接使用STL库中的sort函数进行排序 C/C++代码实现(AC): #include <iostream> #include <algorithm&g

三个数由小到大排序

1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a,b,c; 6 int temp; 7 printf("please input a b c\n"); 8 scanf("%d %d %d",&a,&b,&c); 9 10 if(a>b) 11 { 12 temp=a; 13 a=b; 14 b=temp; 15 16 } 17 if(a>c) 18 { 19 tem

C++对三个数进行排序

#include<iostream> using namespace std; int main() { int a,b,c; cout<<"请输入三个数"<<endl; cin>>a>>b>>c; if(a>b) { if(a>c) { if(b>c) { cout<<"三个数的从小到大的排序为"<<endl; cout<<a<<

13-语言入门-13-三个数从小到大排序

题目地址:?http://acm.nyist.net/JudgeOnline/problem.php?pid=41? ? 描述 现在要写一个程序,实现给三个数排序的功能 输入 输入三个正整数 输出 给输入的三个正整数排序 样例输入 20 7 33 样例输出 7 20 33 ? 代码: #include <stdio.h> static void swap(int *left,int *right); int main() { ???? int a=0,b=0,c=0; ???? scanf(&

随便输入三个数,输出的是将三个数从小到大排列。

#include <stdio.h>int main(){float a,b,c,t;printf("请输入三个实数"); scanf("%f%f%f",&a,&b,&c); if(a>b) {t=a,a=b,b=t; }// 如果输入的是a大于b,那么将A,B互换值,即A大于B:如果B>A,则不进行判断. if(b>c) {t=b,b=c,c=t; }// 如果输入的是b大于c,那么将C,B互换值,即C大于B:

用js写三个数,让三个数从小到大排列

console.log('请输入三个数:'); let num1 = readline.question() - 0; let num2 = readline.question() - 0; let num3 = readline.question() - 0; let num4; if (num1 > num2) { num4 = num1; num1 = num2; num2 = num4; } if (num2 > num3) { num4 = num2; num2 = num3; nu

南阳理工OJ之三个数从小到大排序

------------------------------------------- AC代码: 1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static void main(String[] args) { 7 8 Scanner sc=new Scanner(System.in); 9 10 int x[]=new int[3]; 11 for(int i