sjfb.net
当前位置:首页 >> C语言编程,从键盘输入四个整数,按照数值从小到大... >>

C语言编程,从键盘输入四个整数,按照数值从小到大...

int main() { int i,j,temp; int a[4]; for(i=0;i

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

#include void main() { int a,b,c,d,t; 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>d){t=a;a=d;d=t;} if(b>c){t=b;b=c;c=t;} if(b>d){t=b;b=d;d=t;} if(c>d){t=c;c=d;d=t;} printf("%d %d %d %d\n",a,b...

最愚蠢的方法: # include main() { float a,b,c,d,t; scanf("%f,%f,%f,%f",&a,&b,&c,&d); if(a>b) {t=a;a=b;b=t); if(a>c) {t=a;a=c;c=b}; if(a>d) {t=a;a=d;d=t); if(b>c) {t=b;b=c;c=t}; if(b>d) {t=b;b=d;d=t}; if(c>d) {t=c;c=d;d=t}; prin...

#include int main(void) { int i, j; int arr[10], tmp; printf("十个整数:"); for (i = 0; i < 10; i++) { scanf("%d", &arr[i]); } //输入·十个数 for (j = 1; j

#include"stdio.h" main() {int a[4],i,j; printf("请输入四个整数:\n"); //以空格分开// for(i=0;i

#includeint main( ){ int num[4]; for(int i = 0 ; i < 4 ; i++){ scanf("%d", num+i); } for(int i = 0 ; i < 4 ; i++){ int k = i; for(int j = i+1 ; j < 4 ; j++){ if(num[k] > num[j]){ k = j; } } if(k != i){ int temp = num[k]; num[k]...

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

#include void main() { int a,b,c,d,x; scanf("%d%d%d%d",&a,&b,&c,&d); if(a>b) {x=a;a=b;b=x;} if(a>c) {x=a;a=c;c=x;} if(a>d) {x=a;a=d;d=x;} if(b>c) {x=b;b=c;c=x;} if(b>d) {x=b;b=d;d=x;} if(c>d) {x=c;c=d;d=x;} printf("从小到大顺序...

网站首页 | 网站地图
All rights reserved Powered by www.sjfb.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com