文章
145
粉丝
217
获赞
21
访问
84.3k
#include <stdio.h>
#include <string.h>
//排序
void Sort(int a[],int n)
{
int i,j,t;
for(i = 0; i < n-1; i++)
for(j = 1; j < n-i; j++)
if(a[j] < a[j-1])
{
t = a[j];
a[j] = a[j-1];
a[j-1] = t;
}
}
int main()
{
int a[10000],i = 0,j,n = 0,sign,num;
char s[10000];
scanf("%s",s);
while(s[i] != '\0')
{
j = i;
sign = 1;
num = 0;
if(s[j] == '-')
sign = -1,j++;
while(s[j] >= '0' && s[j] <= '9')
num = num*10+s[j]-'0',j++;
if(s[j] == ',' || s[j] == '\0')
a[n++] = num*sign;
i = j+1;
if(i >= strlen(s)) break;
}
Sort(a,n);
for(i = 0; i < n; i++)
if((i+1) % 4 == 0) printf("%d\n",a[i]);
else printf("%d ",a[i]);
return 0;
}
登录后发布评论
暂无评论,来抢沙发