poj 3366(水题,注意continue的使用)
作者:互联网
#include<iostream> #include<cstring> using namespace std; int main(){ char irr[25][2][25],tgt[25],vowel[]={'a','e','i','o','u'},tail[]={'o','s','x'},tails[][5]={"ch","sh"}; int i,j,l,n,len; bool flag; scanf("%d%d",&l,&n); for(i=0;i<l;i++){ scanf("%s%s",irr[i][0],irr[i][1]); } for(i=0;i<n;i++){ scanf("%s",tgt); len = strlen(tgt); flag = false; for(j=0;j<l;j++){ if(strcmp(tgt,irr[j][0])==0){ printf("%s\n",irr[j][1]); flag = true; break; } } if(flag)continue; flag = false; if(len>1&&tgt[len-1]=='y'){ flag = true; for(j=0;j<5;j++){ if(len>2&&vowel[j]==tgt[len-2]){ flag = false; break; } } } if(flag){ tgt[len-1] = 'i'; tgt[len] = 'e'; tgt[len+1] = 's'; tgt[len+2] = '\0'; printf("%s\n",tgt); continue; } flag = false; for(j=0;j<3;j++){ if(tgt[len-1]==tail[j]){ flag = true; } } if(flag){ strcat(tgt,"es"); printf("%s\n",tgt); continue; } flag = false; for(j=0;j<2;j++){ if(strcmp(tgt+len-2,tails[j])==0){ flag = true; } } if(flag){ strcat(tgt,"es"); printf("%s\n",tgt); continue; } printf("%ss\n",tgt); } return 0; }
标签:25,false,水题,tgt,3366,len,flag,continue,&& 来源: https://www.cnblogs.com/stevenzrx/p/15539294.html