| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
兄弟姐妹们 帮帮忙吧为什么老是不对呢?
#include<stdio.h>
main()
{
int a,b,c,i,j;
int counter[100]={0};
char str[100][50],temp;
scanf("%d %d",&a,&b);
for(i=0;i<a;i++)
{for(j=0;j<b;j++)
{scanf("%c",&str[i][j]);
}
}
for(i=0;i<a;i++)
{for(j=1;j<b;j++)
for(c=0;c<j;c++)
if(str[i][c]>str[i][j]) counter[i]++;
}
for(i=0;i<a-1;i++)
for(j=i+1;i<a;j++)
if(counter[j]<counter[i])
{ for(c=0;c<b;c++)
{
temp=str[i][c];
str[i][c]=str[j][c];
str[j][c]=temp;
}
}
for(i=0;i<a;i++)
for(j=0;j<b;j++)
printf("%c",str[i][j]);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator