www.1862.net > C语言编程题,从键盘输入任意3个数,按从小到大的顺...

C语言编程题,从键盘输入任意3个数,按从小到大的顺...

代码1. // 输入3个数,要求按从小到大顺序输出 #include 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; ...

1、#include int main(){int a,b,c,t;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",a,b,c);return 0;}2、冒泡排序#include int main(){int ...

#includevoid main(){int a,b,c,t;printf("请输入三个整数:a b 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("排序后的三个整数为:%d,%d,%d\n",a,b,c);}

注意本程序中scanf的输入格式,输入整数时,记得按格式,别忘记“,”,呵呵 #include void main() { int a, b, c, d, tem; printf("input four numbers:\n"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); if(a>b) {tem=a;a=b;b=tem;} if(a>c) {tem=a;a=c;...

main() { int a,b,num; scanf("%d%d",&a,&b); if (a>b) {num=a;a=b;b=num;} /*因为a值大,把a值先赋给num,然后把b值赋给a,a就变小,然后把num也就是之前a的大值赋给b,这个时候就把a和b的值交换了。*/ printf("小到大排序: %d %d\n",a,b); } ...

(1)中for(i=0;i

1、只有3个数,可以用判断语句直接调整数的顺序,不用去写排序程序。 2、vb示例: Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer, t As Integer a = Val(InputBox("input a:", , 5)) b = Val(InputBox("input b:"...

#include int main() { int i,j,m; double temp; double a[3]; for(m=0;m

1 读入三个数。 2 循环比较大小,令三个数从小到大排序。 3 输出结果。 代码: #include int main(){ int a,b,c,t; #define swap(m,n){t = m; m = n; n = t;}//交换值宏。 scanf("%d%d%d",&a,&b,&c);//输入三个数。 if(a>b) swap(a,b); if(a>c)s...

#include void main() { int a,b,c; int d,e,f,sum; printf("请输入三个整数:\n"); scanf("%d,%d,%d",&a,&b,&c); //分号放错位置了 sum=a+b+c; d=(a>=b)? a:b; d=(d>=c)? d:c; e=(a

网站地图

All rights reserved Powered by www.1862.net

copyright ©right 2010-2021。
www.1862.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com