标签:
// 有3个数a,b,c,要求按大小顺序把它们输出 #include <stdio.h> int main() { int a[3] ; int i,j; int temp; printf("请输入a,b,c三个数: "); for( i = 0; i < 3; i++ ) { scanf("%d",&a[i]); } for( i = 0; i < 3; i++ ) { for( j = 0; j < (3-i); j++ ) if( a[j] > a[j+1] ) { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; } } printf("这三个数由小到大的排列顺序如下:"); for( i = 0; i < 3; i++ ) { printf("%d ",a[i]); } printf("\n"); return 0; } <img src="http://img.blog.csdn.net/20150423115008746?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhb3lhcWlhbjU1Mg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
标签:
原文地址:http://blog.csdn.net/zhaoyaqian552/article/details/45219775