shwq.net
当前位置:首页 >> 四个整数,按顺序从小到大排列 C语言 >>

四个整数,按顺序从小到大排列 C语言

#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("从小到大顺序...

最愚蠢的方法: # 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...

#includeint main(){ int a, b, c, d, m;printf("输入四个整数:");scanf("%d%d%d%d", &a, &b, &c, &d);if(b>a) {m=a;a=b;b=m;} else if(c>b) {m=c;c=b;b=m;} if(d>c) {m=d;d=c;c=m;} /*至此d成了最小的*/ if(b>a) {m=a;a=b;b=m;} if(c>b) {m=c;c...

#include void main() { int a,b,c,d,e; printf("请分别输入四个数:\n"); scanf("%d%d%d%d",&a,&b,&c,&d); printf("原顺序: %d %d %d %d\n",a,b,c,d); if(a

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

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

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

(1)中for(i=0;i

#include void main() { int a[10]; int i,j,t; printf("input 10 numbers:\n"); for(i=0;i

#include #include using namespace std; #define maxn 1000 int a[maxn]; bool cmp ( int a, int b ) { return a > b; }int main() { int i, n; printf ( "请输入要排序的元素个数:" ); scanf ( "%d", &n ); printf ( "请依次输入%d个数:", n...

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