题意:

输入一个正整数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. [CF276B] Little Girl and Game

    [CF276B] Description 给定字符串 \(S\) ,两人轮流,每次从字符串中任意取出一个字符并从原串中删去.如果某人某次操作前,串种剩余的字符集合经过排列可以得到回文串,那么这个人就胜 ...

  2. MyBatis使用步骤及原理

    主要讲解MyBatis-基本使用步骤      回顾:     MyBatis是一个数据持久层(ORM)框架.把实体 类和SQL语句之间建立了映射关系,是一种半自 动化的ORM实现.MyBATIS需要 ...

  3. python3练习100题——020

    原题链接:http://www.runoob.com/python/python-exercise-example20.html 题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半:再落下 ...

  4. 关于memset....我太难了

    众所周知memset是个清空数组的好东西 然而...它慢的要死 直接让我从30ms炸到1045ms 于是快乐tle .... 是我的错 所以以后还是手动清空 (我真快乐)

  5. MVC5+EF6 入门完整教程4 :EF基本的CRUD

    上篇文章主要讲了如何配置EF, 我们回顾下主要过程: 创建Data Model ---> 创建Database Context --->创建databaseInitializer---&g ...

  6. NOIP做题练习(day1)

    A - Xenny and Alternating Tasks 题面 题解 枚举第一天是谁做,将两个答案取\(min\)即可. 代码 #include <iostream> #includ ...

  7. rocketmq4.4配置日志路径等级

    公司使用了最新的rocketmq框架,然后2天日志跑了快2个g.... 无奈网上只有4.2的教程...只好自己研究 环境rocketmq4.4 springboot 看源码找到配置日志等级和路径的地方 ...

  8. winform学习(3)窗体事件

    窗体的常用事件 事件可以理解为用户的操作,如点击鼠标键盘 应用程序需要在事件发生时进行响应,因此事件分为: 注册事件:必须为对象注册事件才会被执行(如为某控件添加一个单击的事件) 触发事件:注册后的事 ...

  9. 百炼OJ - 1004 - 财务管理

    题目链接:http://bailian.openjudge.cn/practice/1004/ 思路 求和取平均... #include <stdio.h> int main() { fl ...

  10. C++之Boost准标准库配置

    下载安装 进入官网下载地址:https://www.boost.org/users/download/ 本教程直接下载官方已编译库,不涉及源代码手动编译 点击官方编号好的链接,然后进入一个下载地址:h ...