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

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

PAT A1077. Kuchiguse (20/17)

2019-11-11 00:04:06
字體:
來源:轉載
供稿:網友

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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊春市| 怀安县| 梁山县| 佛山市| 富顺县| 收藏| 紫阳县| 长寿区| 樟树市| 休宁县| 福州市| 积石山| 花垣县| 绥化市| 安泽县| 信宜市| 崇礼县| 昆山市| 兴仁县| 海城市| 武山县| 如皋市| 公主岭市| 贵州省| 香港| 凉城县| 古丈县| 武鸣县| 淄博市| 新龙县| 蒙自县| 贵阳市| 那曲县| 北碚区| 唐河县| 安达市| 罗田县| 黔东| 焦作市| 宣武区| 鹤壁市|