HUST Online Judge WebBoard
Problem 4008 >> 总是错误40%,不知道哪里有问题
201901030309 @ 2022-01-13 10:14:16
[ Quote ] [ Edit ] [ Delete ] 1#
#include<stdio.h>
int main()
{
int x,a,b,c,i,j,t,max[2];
scanf("%d",&x);
max[0]=x/100;
max[1]=x/10%10;
max[2]=x%10;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
if(max[j]<max[j+1])
{
t=max[j];
max[j]=max[j+1];
max[j+1]=t;
}
}
}
printf("%d%d%d",max[0],max[1],max[2]);

return 0;
}
202003020118 @ 2022-01-19 13:47:00
[ Quote ] [ Edit ] [ Delete ] 2#
数组定义小了,建议改成max[3]