| ||||||||||
| 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 | |||||||||
请问为啥Output limit exceeded程序如下:
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX=2000;
vector<string> words[MAX];
vector<int> length; //每一列单词格数
int main()
{
string s;
int cnt=0;
while(getline(cin,s)) //Input
{
stringstream ss(s);
string str;
int kase=1,n=0;
while(ss>>str)
{
if(length.size()<kase)
{
length.push_back(str.length());
kase++;
}else{
length[n]=max(length[n],(int)str.length());
}
words[cnt].push_back(str);
n++;
}
cnt++;
}
for(int i=0;i<cnt;i++)
{
int len1=words[i].size();
for(int j=0;j<len1;j++)
{
cout<<words[i][j];
if(j!=len1-1)
{
int len2=words[i][j].length();
for(int k=len2;k<length[j]+1;k++) //多输出一个空格
cout<<' ';
}
}
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