标签:
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; char str1[100005],str2[100005]; bool vis[100005]; int main(){ while(scanf("%s",str1)!=EOF){ getchar(); memset(str2,0,sizeof(str2)); memset(vis,false,sizeof(vis)); scanf("%s",str2); getchar(); int len1=strlen(str1); int len2=strlen(str2); int flag=0; int len; if(len1>len2){ flag=1; len=len1-len2; } else if(len1==len2){ flag=2; len=0; } else if(len1<len2){ flag=3; len=len2-len1; } int End=0; int temp; for(int i=len2-1;i>=0;i--){ temp=0; for(int j=0;j<len1;j++){ if(str2[i]==str1[j]&&!vis[j]){ End++; vis[j]=true; temp=1; break; } } if(temp==0) break; } if(flag==1){ for(int i=0;i<len;i++){ printf("d\n"); } for(int i=0;i<len2;i++){ printf("m %c\n",str2[i]); } } else if(flag==2){ for(int i=0;i<len2;i++) printf("m %c\n",str2[i]); } else if(flag==3){ for(int i=0;i<len;i++){ printf("a %c\n",str2[i]); } for(int i=len;i<len2;i++){ printf("m %c\n",str2[i]); } } memset(str1,0,sizeof(str1)); } return 0; }
Description
Input
Output
Sample Input
Sample Output
标签:
原文地址:http://www.cnblogs.com/13224ACMer/p/4671300.html