10361

A道小水题增加一下题量

就是字符串的模拟,用string的话会方便很多

//============================================================================
// Name        : 10361.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

string s, s0, s1, s2, s3, s4, s5;
int t, N;

int main() {
	scanf("%d", &N);
	getchar();
	while(N--){
		s.clear();
		s0.clear();
		s1.clear();
		s2.clear();
		s3.clear();
		s4.clear();
		s5.clear();
		getline(cin, s);
		getline(cin, s0);
		t = 0;
		while(s[t]!='<'){
			s1 += s[t];
			t++;
		}
		t++;
		while(s[t]!='>'){
			s2 += s[t];
			t++;
		}
		t++;
		while(s[t]!='<'){
			s3 += s[t];
			t++;
		}
		t++;
		while(s[t]!='>'){
			s4 += s[t];
			t++;
		}
		t++;
		while(t < s.length()){
			s5 += s[t];
			t++;
		}
		cout << s1<<s2<<s3<<s4<<s5<<endl;
		for(int i = 0;i < s0.length()-3;i++){
			cout << s0[i];
		}
		cout << s4<<s3<<s2<<s5<<endl;
	}
	return 0;
}

posted @ 2011-06-01 01:03  KOKO's  阅读(248)  评论(0编辑  收藏  举报