题意:

输入一个正整数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. MySQL数据库重点监控指标

    MySQL数据库重点监控指标 QPS queries per seconds 每秒中查询数量 show global status like 'Question%'; Queries/seconds ...

  2. 访问windows共享无法分配内存问题解决

    设置:“HKLMSYSTEMCurrentControlSetControlSession ManagerMemory ManagementLargeSystemCache” 为 “1″ 设置:“HK ...

  3. 使用Powershell开机启动隐藏窗口的程序

    1.打开注册表找到键值:计算机\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 2.添加字符串值:StartJetSer ...

  4. Mongo查询list数组中一个字段大于特定条数

    由于刚刚接触mongodb,很多语法还不是很了解,写的不好的地方请大佬指出 查询的demo数据 { "_id":Object("xxxxxxxx"), &quo ...

  5. selenium + phantomJS 常用方法总结

    0x01 初始化: dcap = dict(DesiredCapabilities.PHANTOMJS)  #一些属性的设置 dcap["phantomjs.page.settings.lo ...

  6. jquery获取ul下的所有li个数

    通过jquery获取ul下所有li的个数(eg) $("ul li").length 通过jquery设置标签css的样式(eg)$("#div").css({ ...

  7. the MTS failed last time时的解决办法

    关于6.6.3SP2版本提示The MTS failed last time 1.1    发生前提条件 在重启系统 shutdown -r now后,网页打不开,发现MTS服务无法启动,我自己涉及的 ...

  8. Mongodb学习笔记(三)性能篇

    一.索引管理 MongoDB提供了多样性的索引支持,索引信息被保存在system.indexes中MongoDB中_id字段在创建的时候,默认已经建立了索引,这个索引比较特殊,并且不可以删除,不过Ca ...

  9. io型和有状态的应用不放入k8s,而是做服务映射

    io型和有状态的应用不放入k8s,而是做服务映射 待办 在实际应用中,一般不会把mysql这种重IO.有状态的应用直接放入k8s中,而是使用专用的服务器来独立部署.而像web这种无状态应用依然会运行在 ...

  10. 吴裕雄 python 机器学习——数据预处理标准化MinMaxScaler模型

    from sklearn.preprocessing import MinMaxScaler #数据预处理标准化MinMaxScaler模型 def test_MinMaxScaler(): X=[[ ...