1077. Kuchiguse (20)
来源:互联网 发布:mac专柜口红价格 编辑:程序博客网 时间:2024/04/29 23:52
1077. Kuchiguse (20)
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:
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
N条句子
看是否有标准结尾;有输出标准结尾,否则“nai”
比如
哈哈
呜呜
输出 nai
比如
読书は学问の术なり、学问は事をなすの术なり
ただ学问を勤めて物事をよく知る者は贵人となり富人となり、无学なる者は贫人となり下人となるなり
输出 なり
评测结果
测试点
#include<iostream> #include<vector> #include<string>using namespace std; int main(){ int N, index, len; bool Flag; cin >> N; getchar();/*吸收换行符*/ vector<string>str(N + 1); for (index = 1; index <= N; index++) getline(cin, str[index]); str[0] = "\0"; Flag = true; len = 0; do { char ctemp; len = str[1].size(); if (len > 0) { ctemp = str[1][len - 1]; str[1].erase(len - 1, 1); } else Flag = false; for (index = 2; index <= N&&Flag; index++) { len = str[index].size(); if (len > 0&& ctemp == str[index][len - 1]) str[index].erase(len - 1, 1); else Flag = false; } if (Flag)str[0] = ctemp + str[0]; } while (Flag); if (str[0].size() > 0)cout << str[0] << endl; else cout << "nai" << endl; system("pause"); return 0;}
- 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- pat 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)
- 染色 - HYSBZ 2243 树链刨分
- Linux系统中查看日志的常用命令
- c++中几种0值的比较问题
- 访问控制符(权限)
- 黑马程序员——反射与正则表达式
- 1077. Kuchiguse (20)
- 黑马程序员——枚举(JDK5的新特性)
- Brainfuck Compiler on PHP
- Python的替换函数——strip(),replace()和re.sub()
- string字符串
- python+Eclipse+pydev环境搭建
- 调整jvm内存大小
- IPv4地址与整型类型互转_Java_PHP_JavaScript
- 零基础学python-4.4 常用的一些内建函数