[ZJ]a104: 排序
題目:
http://zerojudge.tw/ShowProblem?problemid=a104
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
int main()
{
int in0;
while (scanf("%d",&in0)!=EOF){
int in[in0];
for (int i=0;i<in0;i++)
scanf("%d",&in[i]);
for (int i=0;i<in0;i++)
for (int i1=0;i1<in0;i1++)
if (in[i]<in[i1]){
int a;
a=in[i];
in[i]=in[i1];
in[i1]=a;
}
for (int i=0;i<in0;i++)
printf("%d ",in[i]);
printf("\n");
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=a104
------------------------------------------------------------------------------------------
#include<stdio.h>
#include<stdlib.h>
int main()
{
int in0;
while (scanf("%d",&in0)!=EOF){
int in[in0];
for (int i=0;i<in0;i++)
scanf("%d",&in[i]);
for (int i=0;i<in0;i++)
for (int i1=0;i1<in0;i1++)
if (in[i]<in[i1]){
int a;
a=in[i];
in[i]=in[i1];
in[i1]=a;
}
for (int i=0;i<in0;i++)
printf("%d ",in[i]);
printf("\n");
}
return 0;
}
留言
張貼留言