国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

PAT A1077. Kuchiguse (20/17)

2019-11-10 22:56:01
字體:
來源:轉載
供稿:網友

The Japanese language is notorious for its sentence ending particles. Personal PReference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called "Kuchiguse" and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle "nyan~" is often used as a stereotype for characters with a cat-like personality:

Itai nyan~ (It hurts, nyan~)Ninjin wa iyada nyan~ (I hate carrots, nyan~)

Now given a few lines spoken by the same character, can you find her Kuchiguse?

Input Specification:

Each input file contains one test case. For each case, the first line is an integer N (2<=N<=100). Following are N file lines of 0~256 (inclusive) characters in length, each representing a character's spoken line. The spoken lines are case sensitive.

Output Specification:

For each test case, print in one line the kuchiguse of the character, i.e., the longest common suffix of all N lines. If there is no such suffix, write "nai".

Sample Input 1:
3Itai nyan~Ninjin wa iyadanyan~uhhh nyan~Sample Output 1:
nyan~Sample Input 2:
3Itai!Ninjinnwaiyada T_TT_TSample Output 2:
nai
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define Max 300using namespace std;struct user{	char name[11];	char pas[11];}a[Max],b[Max];char getc(char a[],int m){	return a[strlen(a)-1-m];}int main(){	char la[Max][Max];	int n,k=0,f=1;	scanf("%d",&n);	getchar();	for(int i=0;i<n;i++){				gets(la[i]);	}	while (f==1){	for(int i=0;i<n-1;i++)	{		if(getc(la[i+1],k)!=getc(la[i],k)){			f=0;			break;		}	}	  if(f==1)  k++;	  else break;	}	if(k==0) printf("nai/n");	else {		for(int i=strlen(la[0])-k;i<strlen(la[0]);i++)			printf("%c",la[0][i]);	}	system("pause");	return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安塞县| 临朐县| 常州市| 遂昌县| 琼结县| 潜江市| 铜陵市| 浙江省| 峨山| 封丘县| 西吉县| 获嘉县| 日照市| 那曲县| 南和县| 石楼县| 门头沟区| 蛟河市| 伊宁县| 华蓥市| 天台县| 出国| 钟山县| 阳高县| 凭祥市| 越西县| 固阳县| 莆田市| 海安县| 康保县| 香港 | 开阳县| 揭东县| 卓资县| 海盐县| 怀仁县| 阳西县| 泰兴市| 无棣县| 渭源县| 莱州市|