| ||||||||||
| 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 | |||||||||
帮看一下有什么不对的地方//============================================================================
// Name : 1056IMME.cpp
// Author : kevin
// Version :
// Copyright : copyright @ kevin
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
string tmp1,tmp2;
int cases=0;
int len;
bool flag;
string s[10000];
int cnt=0;
while(cin>>tmp1){
flag=false;
s[cnt++]=tmp1;
while(cin>>tmp2){
if(tmp2=="9"){
cases++;
break;
}
s[cnt++]=tmp2;
}
sort(s,s+cnt);
for(int i=0;i<cnt;i++){
len=s[i].length();
for(int j=i+1;j<cnt;j++){
string sub=s[j].substr(0,len);
if(s[i]==sub){
cout<<"Set "<<cases<<" is not immediately decodable"<<endl;
flag=true;
break;
}
}
if(flag)
break;
}
if(!flag)
cout<<"Set "<<cases<<" is immediately decodable"<<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