HDU1073字符串处理

1.getline(cin, s)会将末尾’\n’去掉。

#include
#include
using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		string start, end;;
		string s,s_, s2, s2_, S, S2;
		s.clear();
		s2.clear();
		S.clear();
		S2.clear();
		
		cin >> start;
		
		for(int i = 0;;i++){
			getline(cin, s_);
			if(s_ == "END")
				break;
			s += (s_ + '\n');
		}
		
		cin >> start;
		int i = 0;
		for(int i = 0;;i++){
			getline(cin, s2_);
			if(s2_ == "END")
				break;
			s2 += (s2_ + '\n'); 
		}
		
		int flag = 0;
		if(s == s2){
			cout << "Accepted" << endl;
			flag = 1;
			continue;
		}
		for(int i  = 0; i < s.size(); i++)
			if(s[i] != '\n' && s[i] != '\t' && s[i] != ' ' ){
				S += s[i];
			}
		for(int i  = 0; i < s2.size(); i++)
			if(s2[i] != '\n' && s2[i] != '\t' && s2[i] != ' ' ){
				S2 += s2[i]; 
			}
		if(S == S2){
			cout << "Presentation Error" << endl;
			continue;
		}
		cout << "Wrong Answer" << endl;
	} 
} 

你可能感兴趣的:(HDU1073字符串处理)