Start: Jul, 03, 2019 08:38:00
2019年度暑期短学期第七天 助教场
End: Jul, 04, 2019 23:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 3ms
Memory: 1140kB
Author: 2018212212029
In contest: 1292

#include<string.h>
#include<stdio.h>
char str[10001];
char str2[10006];
int main() {
	int n,x;
	scanf("%d",&n);
	getchar();
	while(n--) {
		x=-1;
		gets(str); 
		int len=strlen(str);
		for(int i=0;i<len;i++){
			if(str[i]=='p'&&str[i+1]=='r'&&str[i+2]=='i'&&str[i+3]=='n'&&str[i+4]=='t'&&str[i+5]==' '){
				x=i+5;
				break;
			}
		}
		if(x==-1){
			printf("%s\n",str);
			continue;
		}
		for(int i=0;i<x;i++) {
			str2[i]=str[i];
		}
		str2[x]='(';
		for(int i=x+1;i<len;i++){
			str2[i]=str[i];
		}
		str2[len]=')';
		for(int i=0;i<=len;i++){
			printf("%c",str2[i]);
		}
		printf("\n");
	}
}