题意:

输入一个正整数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. Spectral clustering谱聚类

    Basic knowledge: degree matrix; similarity matrix, and Adjacency matrix; 无向带权图模型 G=<V,E>G=< ...

  2. 给html元素添加自定义属性,并且用jquery进行筛选

    例如有多个div,想要实现类似radio的效果. <div name="teacher" selected="selected">tch1</ ...

  3. appium---webview(H5)元素定位

    我们在做UI自动化的时候,肯定需要元素定位,那么webview(H5)的元素怎么定位呢? webview定位方法 方法一: 1.打开chrome浏览器,输入chrome://inspect 2.连接手 ...

  4. 安装node.js后npm不可用

    安装node.js后npm不可用 最近要用Vue做项目,依赖node.js,于是按官网下载安装node 下载地址:https://nodejs.org/en/download/ 网上也有很多教程这里就 ...

  5. AcWing 8.二维费用的背包问题

    #include<iostream> #include<algorithm> #include<cstring> using namespace std ; ; i ...

  6. Mysql中的触发器【转】

    转载:https://www.cnblogs.com/chenpi/p/5130993.html 阅读目录 什么是触发器 特点及作用 例子:创建触发器,记录表的增.删.改操作记录 弊端 什么是触发器 ...

  7. 虚拟机NAT模式联网

    阿里开源镜像软件:https://opsx.alibaba.com/mirror 如何使VMware ip与本机ip处于同一网段 https://blog.csdn.net/kakuma_chen/a ...

  8. 微服务监控平台获取网关(zuul)配置列表

    步骤: (1)读取zuul的配置文件,获取路由配置项信息: private static Properties props; static { String fileName = "appl ...

  9. 【14】 DFS 机器人活动范围 (static插曲)

    题目 地上有一个m行n列的方格,从坐标 [0,0] 到坐标 [m-1,n-1] .一个机器人从坐标 [0, 0] 的格子开始移动,它每次可以向左.右.上.下移动一格(不能移动到方格外),也不能进入行坐 ...

  10. makecert生成证书

    是要命令 makecert -r -pe -n "cn=musetowc" -$ commercial -a sha1 -b 01/01/2020 -e 01/01/2050 -c ...