| ||||||||||
| 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 | |||||||||
哪位大哥帮忙看看啊!题目给的测试数据过了,可是Runtime Error了!!!#include <iostream.h>
#include <string.h>
void main()
{
int i,n,j,s,k,h,temp,b[102];
char a[52][102];
char str;
cin>>n>>s;
for (i=1;i<=s;i++)
{
for (j=1;j<=n;j++)
cin>>a[i][j];
}
for (i=1;i<=s;i++)
{
h=0;
for (j=1;j<=n;j++)
{
for (k=n;k>j;k--)
{
if (a[i][j]>a[i][k])
h++;
}
}
b[i]=h;
}
for (i=1;i<=s;i++)
{
for (j=s;j>i;j--)
{
if (b[j-1]>b[j])
{
temp=b[j];
b[j]=b[j-1];
b[j-1]=temp;
for (k=1;k<=n;k++)
{
str=a[j][k];
a[j][k]=a[j-1][k];
a[j-1][k]=str;
}
}
}
}
for (i=1;i<=s;i++)
{
for (j=1;j<=n;j++)
cout<<a[i][j];
cout<<endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator