Start: Jan, 04, 2017 19:40:00
2016年秋季学期程序设计基础期末考试
End: Jan, 04, 2017 21:40:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 1ms
Memory: 1700kB
Author: mmseasons
In contest: 1084

#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>

using namespace std;
int main(){
	int t;
	cin>>t;
	getchar();
	while(t--){
		char a[110]="",b[110]="";
		gets(a);
		for(int i=0;i<strlen(a);i++){
			if(a[i]>='A'&&a[i]<='Z')b[i]=a[i]-'A'+'a';
			else b[i]=a[i];
		}
		string ans=b;
		int afr[110]={0},ssr[110]={0};
		while(ans.find("africa")!=-1){
			afr[ans.find("africa")]+=1;
			ans[ans.find("africa")]='A';
		}
		while(ans.find("ssr")!=-1){
			ssr[ans.find("ssr")]+=1;
			ans[ans.find("ssr")]='S';
		}
		for(int i=0;i<strlen(a);i++){
			if(ssr[i]){
				printf("***");
				i+=2;
			}
			else if(afr[i]){
				printf("AFRICA");
				i+=5;
			}
			else printf("%c",a[i]);
		}
		cout<<endl;
	}


}