题目大意:根据题目将字符串进行转换

解体思路:找到所需要替换的内容,存储在字符串中,再进行输出

#include<cstdio>
#include<cstring>

int main() {

	char str[300];
	char s[3000];
	char *st[100];
	int number;
	int len;
	int mark = 0;
	int i;
	int test;
	scanf("%d\n", &test);
	for(int i = 0 ; i < test * 2; i++) {
		gets(str);
		strcat(s,str);
		s[strlen(s)] = '\n';
	}
	len = strlen(s);
	char s1[100], s2[100], s3[100], s4[100] ;
	memset(s2,'\0',sizeof(s2));
	memset(s3,'\0',sizeof(s3));
	memset(s4,'\0',sizeof(s4));
	memset(s1,'\0',sizeof(s1));

	for(  i = 0 ; i < len ; i++ ) {
		if(mark != test) {
			if(s[i] == '<') {
				int k = i;
				k++;//跳过字符<
				for(int j = 0; s[k] != '>' ; j++, k++) {
					s1[j] = s[k];	
				}
				k++;//跳过字符>
				for(int j = 0; s[k] != '<'; j++,k++ )
					s2[j] = s[k];
				for(  ; k < len; k++ ) {
					if(s[k] == '<') {
						k++;//跳过字符<
						for(int j = 0; s[k] != '>' ; k++, j++) {
							s3[j] = s[k];	
						}
						k++;//跳过字符>
						for(int j = 0; s[k] != '\n'; j++, k++ )
							s4[j] = s[k];
						break;
					}
				}
				printf("%s%s%s%s", s1, s2, s3,s4);
				i = k;
			}
			if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				i = i + 3;
				printf("%s%s%s%s",s3 ,s2, s1, s4);	
				mark++;
				memset(s2,'\0',sizeof(s2));
				memset(s3,'\0',sizeof(s3));
				memset(s4,'\0',sizeof(s4));
				memset(s1,'\0',sizeof(s1));
				if(mark == test) {//少了这个就多出了个空格
					printf("\n");
					return 0;
				}
			}
		}
		printf("%c",s[i]);
	}
	return 0;
}