PAT Advanced Level 1077. Kuchiguse (20)
来源:互联网 发布:矩阵的秩与线性相关 编辑:程序博客网 时间:2024/05/14 19:05
【来源】
1077. Kuchiguse (20)
【分析】
暂略,有空来填坑。
【代码】
#include <algorithm>#include <iostream>#include <string>#include <vector>using namespace std;string commonsuffix(string s1, string s2){ string::const_reverse_iterator i1; string::const_reverse_iterator i2; string res = ""; for (i1 = s1.crbegin(),i2 = s2.crbegin(); i1 != s1.crend() && i2 != s2.crend(); ++i1, ++i2){ if (*i1 != *i2){ break; } res = *i1 + res; } return res;}int main(){ int N; cin >> N; getchar(); string line; vector<string> lines; for (int ca = 0; ca < N; ++ca){ getline(cin, line); lines.push_back(line); } string suffix = lines[0]; for (int i = 1; i < N; ++i){ suffix = commonsuffix(suffix, lines[i]); } if (suffix.size() != 0){ cout << suffix << endl; } else{ cout << "nai" << endl; } system("pause"); return 0;}
【点评】
本题为简单的字符串处理题。
0 0
- PAT Advanced Level 1077. Kuchiguse (20)
- PAT (Advanced Level) 1077. Kuchiguse (20)
- 【PAT】【Advanced Level】1077. Kuchiguse (20)
- PAT (Advanced level) 1077. Kuchiguse (20) 最长共同后缀
- PAT (Advanced Level) Practise 1077Kuchiguse (20)
- PAT (Advanced Level) Practise 1077 Kuchiguse (20)
- PAT (Advanced) 1077. Kuchiguse (20)
- 1077. Kuchiguse (20)【字符串处理】——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1077(Kuchiguse)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- pat 1077. Kuchiguse (20)
- PAT 1077. Kuchiguse (20)
- 【PAT】1077. Kuchiguse (20)
- C++游戏开发需要阅读的书籍 (转)
- window7下用IIS建站点及配置
- hdu1010 Tempter of the Bone
- hdf5 vs cpickle
- Java出现No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- PAT Advanced Level 1077. Kuchiguse (20)
- 华为初级——提取不重复的整数
- memmove、memcpy和memccpy 对比
- UVa:400 - Unix ls
- HDU 1026 Ignatius and the Princess I
- 英文资料翻译
- gluPerspective and gluLookAtmain.c
- android:启动服务;广播(最高优先窃听信息)并转发给别人
- 大一C语言课程设计--飞机订票系统