| ||||||||||
| 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 | |||||||||
三重循环法的 无法解释的Wrong.........(what's wrong???????????)#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<string> s(1000);
int K=0;
string t;
while(getline(cin,t))
{
if(t=="EOF")break;
if(t.size()<2)//输入关键!!!!!如何知道输入空行!!!
{
int n=K;
int a,b,c;
int num=0;
cout<<"CARDS: ";
for(K=0;K<n;++K)
cout<<s[K]<<" ";
cout<<endl;
cout<<"SETS: ";
for(a=0;a<n;++a)
for(b=a+1;b<n;++b)
for(c=b+1;c<n;++c)
{
int p=1;
for(K=0;K<4;++K)
{
//如果不是三个量 相等 或 两两互不相等 则跳过
if( !( (s[a][K]!=s[b][K] && s[b][K]!=s[c][K] && s[c][K]!=s[a][K]) ||
(s[a][K]==s[b][K] && s[b][K]==s[c][K] && s[c][K]==s[a][K]) ) )
{ p=0;break;}
}
if(p==0)continue;
else
{
++num;
if(num>1)cout<<" ";
cout<<num<<". "<<s[a]<<" "<<s[b]<<" "<<s[c]<<endl;
}
}
if(num==0)cout<<"*** None Found ***"<<endl;
cout<<endl;
K=0;
continue;
}
s[K++]=t;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator