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

怎么就WA了?

Posted by gbchqc at 2010-03-08 17:12:40 on Problem 2681 and last updated at 2010-03-08 17:13:02
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	cin>>n;
	string s1,s2;
	char ch[255];
	for(int i=0;i<n;i++){
		fflush(stdin);
		cin.getline(ch,255);
		s1=ch;
		cin.getline(ch,255);
		s2=ch;
		int d=0;
		string::iterator it2=s2.begin();
		for(int j=0;j<s1.length();j++){
			for(int k=0;k<s2.length();k++){
				if(s1[j]==s2[k]){
					s2.erase(it2+k);
					d++;
					break;
				}
			}
		}
		cout<<"Case #"<<i+1<<":  "<<s1.length()+s2.length()-d<<endl;
	}
	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