【c语言】输入3个数,要求按从小到大顺序输出

// 输入3个数,要求按从小到大顺序输出

#include <stdio.h>

int main()
{
	int a,b,c,t;
	printf("请输入三个数:");
	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("从小到大的顺序是:%d  %d  %d\n",a,b,c);
	return 0;
}

<img src="http://img.blog.csdn.net/20150423121730658?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhcWlhbjU1Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />

时间: 2024-08-29 14:44:43

【c语言】输入3个数,要求按从小到大顺序输出的相关文章

【C语言】要求任意输入10个数,然后按从小到大顺序输出

//要求任意输入10个数,然后按从小到大顺序输出 #include <stdio.h> int main() { int a[10]; int i,j; int temp; printf("请输入10个整数:"); for(i=0;i<10;i++) { scanf("%d",&a[i]); } for(i=0;i<9;i++) { for(j=0;j<9-i;j++) { if(a[j]>a[j+1]) { temp=a

输入三个数a,b,n,输出a和b不大于n的公倍数的个数

题:输入三个数a,b,n,输出a和b不大于n的公倍数的所有个数. 这题的思想是先求得a和b的最大公约数,然后用a和b的积除以最大公约数,得到最小公倍数,再持续加上最小公倍数,直到超过n,记下n的个数.如:8,12,100,最大公约数为4,则最小公倍数为24.则公倍数为:24.48.72.96,即总共有4个. 代码如下: 1 #include<iostream> 2 #include<algorithm> 3 4 using namespace std; 5 6 int main()

c语言:输入4个整数,要求按从小到大的顺序输出。

输入4个整数,要求按从小到大的顺序输出. 解:程序: #include<stdio.h> int main() { int t,a,b,c,d; printf("请输入4个数:"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); if (a > b) { t = a; a = b; b = t; } if (a > c) { t = a; a = c; c = t; } if (a >

有一个从小到大排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> //有一个从小到大排好序的数组.现输入一个数,要求按原来的规律将它插入数组中. var arr = [1, 2, 3, 4, 5, 7, 9]; function insertScot

C语言:输入一个数,输出比这个数小的所有素数,并求出个数。

//C语言:输入一个数,输出比这个数小的所有素数,并求出个数. 1 #include<conio.h> 2 #include<stdio.h> 3 #include<stdlib.h> 4 #define MAX 100 5 int fun(int lim, int aa[MAX]) 6 { 7 int i, j,k=0; 8 for (i = 2; i <= lim; i++)//罗列每个数 9 { 10 for (j = 2; j < i; j++)//

输入5个数用冒泡排序进行从小到大排列

package liu0913; import java.util.Scanner; public class Maopao { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入第一个数"); int a=sc.nextInt(); System.out.println("请输入第二个数"); int b=sc.nex

【转载】C语言 构建参数个数不固定函数

深入浅出可变参数函数的使用技巧本文主要介绍可变参数的函数使用,然后分析它的原理,程序员自己如何对它们实现和封装,最后是可能会出现的问题和避免措施. VA函数(variable argument function),参数个数可变函数,又称可变参数函数.C/C++编程中,系统提供给编程人员的va函数很少.*printf()/*scanf()系列函数,用于输入输出时格式化字符串:exec*()系列函数,用于在程序中执行外部文件(main(int argc,char*argv[]算不算呢,与其说main

C语言K&R习题系列——统计文档中每个单词所占字母个数,以直方图形式输出

原题: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging. 这也是我第一个过百行的代码(带注释,空格什么的) 主要分两个部分:输入和输出 #include < stdio.h > #define

输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。

ASCII码排序 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符. 输入 第一行输入一个数N,表示有N组测试数据.后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格. 输出 对于每组输入数据,输出一行,字符中间用一个空格分开. 样例输入 2 qwe asd 样例输出 e q w a d s #include <iostream> using namespace