Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

三重循环法的 无法解释的Wrong.........(what's wrong???????????)

Posted by wcfairytale at 2007-02-15 17:41:10 on Problem 1053
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator