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

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

#include int main(){ int s=0,a,b,c; scanf("%d%d%d",&a,&b,&c); if(a>b) { s=a; a=b; b=s; } if(a>c) { s=a; a=c; c=s; }if(b>c) { s=b; b=c; c=s; } printf("%d\t%d\t%d\n",a,b,c); getchar(); getchar(); return 0;}

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

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

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

int main(int argc, const char * argv[]) { int a[3] = {0}; printf("输入三个整数空格隔开:\n"); for (int i = 0; i < 3; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2 - i; j++) { if (a[j] > a[j + 1...

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

问题:输入三个数x,y,z,把其中的最大值赋值给x,中间赋值给y,最小值赋值给z。 参考代码: #include "stdio.h" int main() { int x,y,z,max,min; scanf("%d%d%d",&x,&y,&z); if(x>y){ max=x; min=y; } if(z>max) max=z; if(min>z) min=z; y=x+y...

网站地图

All rights reserved Powered by www.1862.net

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