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

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

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 ...

代码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; ...

注意本程序中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;...

#include "stdio.h" main() { int x,y,z,t; scanf("%d%d%d",x,y,z); if (x>y) { t=x;x=y;y=t; } /*交换x,y的值*/ if(x>z) { t=z;z=x;x=t; }/*交换x,z的值*/ if(y>z) { t=y;y=z;z=t; }/*交换z,y的值*/ printf("small to big: %d %d %d\n",x,y,z); }

#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);}

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); } ...

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

#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

#include void sort(int *p, int *q, int *t) { int temp; if(*p > *q) { temp = *p; *p = *q; *q = temp; } if(*p > *t) { temp = *t; *t = *p; *p = temp; temp = *q; *q = *t; *t = temp; } else if(*q > *t) { temp = *q; *q = *t; *t= temp...

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:"...

网站地图

All rights reserved Powered by www.1862.net

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