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

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

PAT A1077. Kuchiguse (20/17)

2019-11-11 01:34:11
字體:
來源:轉載
供稿:網友

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;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 休宁县| 沙雅县| 乌兰察布市| 六盘水市| 凌源市| 固安县| 竹山县| 阿克苏市| 读书| 红原县| 扎鲁特旗| 南城县| 云安县| 成安县| 漯河市| 马鞍山市| 仁布县| 呈贡县| 镇江市| 邯郸县| 通道| 拜城县| 栖霞市| 乐东| 财经| 黑河市| 工布江达县| 积石山| 东兴市| 图们市| 蒲城县| 临汾市| 抚远县| 盐山县| 临西县| 随州市| 会泽县| 南宫市| 资兴市| 通道| 漾濞|