题意:

输入一个正整数N(<=100),接着输入N行字符串。输出N行字符串的最长公共后缀,否则输出nai。

AAAAAccepted code:

 #include<bits/stdc++.h>
using namespace std;
string s[];
int length[];
char ans[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
cin.ignore();
int mn=;
for(int i=;i<=n;++i){
getline(cin,s[i]);
length[i]=s[i].size();
mn=min(mn,length[i]);
}
int cnt=;
for(int x=;x<=mn;++x){
int flag=;
for(int i=;i<=n;++i)
if(s[i][length[i]-x]!=s[i-][length[i-]-x]){
flag=;
break;
}
if(flag)
break;
ans[++cnt]=s[][length[]-x];
}
if(!cnt)
cout<<"nai";
else
for(int i=cnt;i;--i)
cout<<ans[i];
return ;
}

【PAT甲级】1077 Kuchiguse (20 分)(cin.ignore()吃掉输入n以后的回车接着用getine(cin,s[i])输入N行字符串)的更多相关文章

  1. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  2. PAT甲级——1077.Kuchiguse(20分)

    The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...

  3. PAT Advanced 1077 Kuchiguse (20 分)

    The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...

  4. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  5. PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)

    1061 Dating (20 分)   Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...

  6. PAT甲级——1035 Password (20分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  7. PAT 甲级 1077 Kuchiguse

    https://pintia.cn/problem-sets/994805342720868352/problems/994805390896644096 The Japanese language ...

  8. PAT甲级——1061 Dating (20分)

    Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkg ...

  9. PAT甲级——1005.SpellItRight(20分)

    Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...

随机推荐

  1. 服务遇到的问题 Linux

    1.vnc配置: https://www.cnblogs.com/leolzi/p/9907856.html 2.遇到的问题,linux重启后不能链接的问题 rabbitmq 服务启动问题 [bf@l ...

  2. Laravel 中使用 Laravel-Excel 美化

    <?php use Maatwebsite\Excel\Classes\LaravelExcelWorksheet; use Maatwebsite\Excel\Exceptions\Larav ...

  3. mysql之instr函数

    1.用于模糊查询,做为过滤条件 ---------------------------上级的新闻下级可以看到-------------------------SELECT a.pk_cms_nrgl_ ...

  4. MySQL数据库、数据表和字段字符集查询、修改和配置

    一.设置编码 LINUX  修改vi/etc/my.cnf WINDOWS my.ini 在[client]下添加    default-character-set=utf8 在[mysqld]下添加 ...

  5. Go操作Elasticsearch

    文章转自   Elasticsearch Elasticsearch 下载 https://www.elastic.co/cn/start 运行 解压后cd到解压目录 ./bin/elasticsea ...

  6. AJAX-状态属性

    XMLHttpRequest对象的readyState属性 作用:表示xhr对象的请求状态 值:由0到4表示5个状态 0:请求尚未初始化 1:已经打开到WEB服务器的连接,正在向服务器发送请求 2:请 ...

  7. CentOS6.10 Nginx无法解析php文件

    一 .问题描述: 1). 前提: nginx 已经安装完毕,并且能够访问 2). 问题: 当访问 .php 文件时会默认下载,或者提示 “File not found.” 3). 本机环境 PHP 版 ...

  8. python"TypeError: 'NoneType' object is not iterable"错误解析

    尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...

  9. python测量代码运行时间方法

    Python 社区有句俗语: “python自己带着电池” ,别自己写计时框架. Python3.2具备一个叫做 timeit 的完美计时工具可以测量python代码的运行时间. timeit 模块: ...

  10. RMQ入门解析

    参照大佬博客:https://www.cnblogs.com/yoke/p/6949838.html RMQ(Range Minimum/Maximum Query),  是一种问题,即 查询给定区间 ...