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

首頁 > 學院 > 開發(fā)設計 > 正文

PAT A1077. Kuchiguse (20/17)

2019-11-10 23:54:29
字體:
來源:轉載
供稿:網友

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;}
上一篇:1051. Pop Sequence (25)

下一篇:二叉平衡樹

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 梨树县| 新郑市| 旅游| 吉木萨尔县| 东明县| 桂林市| 方正县| 湘潭市| 宣汉县| 和林格尔县| 宕昌县| 深州市| 普宁市| 桃江县| 湘乡市| 时尚| 拉萨市| 揭西县| 大化| 乐陵市| 文化| 大埔县| 通辽市| 察雅县| 滨海县| 台东市| 枣庄市| 崇左市| 界首市| 资源县| 长兴县| 新郑市| 三明市| 乌鲁木齐市| 丰原市| 满城县| 湘潭市| 湘潭市| 武胜县| 新安县| 仁怀市|