| ||||||||||
| 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 | |||||||||
请教高手1007?我的程序显示错误为:RUNTIME ERROR
什么原因呢?
如下:
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
int sort(string s){
int result=0;
for(int i=0;i<s.length();i++)
for(int j=i;j<s.length();j++)
if(s[i]>s[j])result++;
return result;
}
int main(){
int num,lenth;
string str;
vint sortness;
vstr s;
cin>>lenth>>num;
for(int i=0;i<num;i++){
cin>>str;
s.push_back(str);
sortness.push_back(sort(s[i]));
}
for(int m=0;m<num;m++)
for(int n=m+1;n<num;n++){
string temp;
int temp2;
if(sortness[m]>sortness[n]){
temp=s[m];
s[m]=s[n];
s[n]=temp;
temp2=sortness[m];
sortness[m]=sortness[n];
sortness[n]=temp2;
}
}
for(int k=0;k<s.size();k++)
cout<<s[k]<<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