| ||||||||||
| 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 | |||||||||
诡异,用cout输出字符串一直OLE,但改成一个字符一个字符输出以后就AC了,请大牛指教#include <iostream>
using namespace std;
int sort(char * s, int length)
{
int unsortedness = 0;
for(int i=0;i < length-1;i++)
{
for(int j=i+1;j<length;j++)
{
if( s[i] > s[j]) unsortedness++;
}
}
return unsortedness;
}
void swap(int & a,int & b)
{
int temp;
temp = a;
a = b;
b = temp;
}
int main( )
{
char DNA[100][50];
int DNAUNSortedness[100];
int out[100];
for(int i=0;i<100;i++)
{
out[i] = i;
}
int n,m;
cin>>n>>m;
for(int i = 0; i < m; i++)
{
cin>>DNA[i];
DNAUNSortedness[i] = sort(DNA[i],n);
getchar();
}
for( int i = 0;i < m-1;i++)
{
for( int j = i + 1;j < m;j++)
{
if( DNAUNSortedness[i] > DNAUNSortedness[j])
{
swap(out[i],out[j]);
swap(DNAUNSortedness[i],DNAUNSortedness[j]);
}
}
}
for(int i = 0;i < m;i++) //诡异,将输出改为for(int i = 0;i < m;i++)
{
for(int j=0;j< n;j++) //cout<<DNA[out[i]]<<endl;提交则显示OLE(Output Limit Exceeded)
cout<<DNA[out[i]][j];
cout<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator