problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing779类 参考

AcWing 779. 最长公共字符串后缀 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 779. 最长公共字符串后缀

在文件 acwing.h1344 行定义.

成员函数说明

◆ main()

int acwing::acwing779::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp4351 行定义.

4351 {
4352 while(true) {
4353 int n;
4354 cin >> n;
4355 if(n == 0) {
4356 break;
4357 }
4358 string suffix;
4359 cin >> suffix;
4360 for(int i = 1; i < n; i++) {
4361 string str;
4362 cin >> str;
4363 if(!suffix.empty()) {
4364 auto ss = stringstream();
4365 for(int j = 0; j < min(str.length(), suffix.length()) && suffix[suffix.length() - 1 - j] == str[str.length() - 1 - j]; j++) {
4366 ss << suffix[suffix.length() - 1 - j];
4367 }
4368 string s = ss.str();
4369 suffix = string(s.rbegin(), s.rend());
4370 }
4371 }
4372 cout << suffix << endl;
4373 }
4374 return 0;
4375 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: