|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
/*输入a,b,c,d四个数并对其排序*/
#include<stdio.h>
int bigger(int x, int y)
{
return((x>=y)?x:y);
}
int smaller(int x, int y)
{
return((x<y)?x:y);
}
void main()
{
int a, b, c, d, x, y, z, w ;
int x1, y1, z1, w1, x2, y2, z2, w2 ;
scanf("%d%d%d%d",&a,&b,&c,&d);
x = bigger(a,b);
y = smaller(a,b);
z = bigger(c,d);
w = smaller(c,d);
x1 = bigger(a,c);
y1 = smaller(a,c);
z1 = bigger(b,d);
w1 = smaller(b,d);
x2 = bigger(a,d);
y2 = smaller(a,d);
z2 = bigger(b,c);
w2 = smaller(b,c);
if (y>=z)
{
printf("%d>=%d>=%d>=%d",x,y,z,w);
}
else if (w>=x)
{
printf("%d>=%d>=%d>=%d",z,w,x,y);
}
else if (y1 >= z1)
{
printf("%d>=%d>=%d>=%d",x1,y1,z1,w1);
}
else if (w1 >= x1)
{
printf("%d>=%d>=%d>=%d",z1,w1,x1,y1);
}
else if (y2 >= z2)
{
printf("%d>=%d>=%d>=%d",x2,y2,z2,w2);
}
else if (w2 >= x2)
{
printf("%d>=%d>=%d>=%d",z2,w2,x2,y2);
}
}
===========================================================
PS E:\Administrator\Documents\Visual Studio 2019> & 'c:\Users\Administrator\.vscode\extensions\ms-vscode.cpptools-0.22.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-j2eztiyu.qz0' '--stdout=Microsoft-MIEngine-Out-rtljik2c.ssw' '--stderr=Microsoft-MIEngine-Error-x1fx3j5m.wgw' '--pid=Microsoft-MIEngine-Pid-1iqaojfl.hkp' '--dbgExe=E:\MingGW\bin\gdb.exe' '--interpreter=mi'
900
900
600
100
900>=900>=600>=100
PS E:\Administrator\Documents\Visual Studio 2019>
PS E:\Administrator\Documents\Visual Studio 2019> & 'c:\Users\Administrator\.vscode\extensions\ms-vscode.cpptools-0.22.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-j0juibej.yfw' '--stdout=Microsoft-MIEngine-Out-uplwpx1u.0fr' '--stderr=Microsoft-MIEngine-Error-y0i2ipp1.aun' '--pid=Microsoft-MIEngine-Pid-31pqvaqo.esm' '--dbgExe=E:\MingGW\bin\gdb.exe' '--interpreter=mi'
100
0
0
3
100>=3>=0>=0
PS E:\Administrator\Documents\Visual Studio 2019>
两两比较就好了啊 #include<stdio.h>
int main()
{
int a,b,c,d,e;
printf("请输入四个数:");
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a<b)
{
e=a;
a=b;
b=e;
}
if(a<c)
{
e=a;
a=c;
c=e;
}
if(a<d)
{
e=a;
a=d;
d=e;
}
if(b<c)
{
e=b;
b=c;
c=e;
}
if(b<d)
{
e=b;
b=d;
d=e;
}
if(c<d)
{
e=c;
c=d;
d=e;
}
printf("按小到大排序 %d %d %d %d\n",d,c,b,a);
}
|
|