PAT甲级-1140 Look-and-say Sequence (20 分)
发布日期:2022-02-10 08:11:03 浏览次数:8 分类:技术文章

本文共 509 字,大约阅读时间需要 1 分钟。

题目:
分析:模拟。第一次看题,意思理解了一会┭┮﹏┭┮

例如第一个是:11231,那么下一个就是:12213111

因为第一个中有2个1,1个2,1个3,1个在这里插入代码片1,所以对应的是:12,21,31,11

#include
#include
#include
#include
#include
#include
#include
using namespace std;int n,m,k;int main(){ string s; cin>>s>>m; for(int i = 0 ; i < m-1 ; i++) { int len = s.size(); string t = ""; for(int j = 0 ; j < len ;j++) { char c = s[j]; int cnt = 0; while(s[j] == c) { cnt++; j++; } j--; t += c; t += to_string(cnt); } s = t; } cout<

转载地址:https://blog.csdn.net/qq_43567222/article/details/114365700 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:PAT甲级-1139 First Contact (30 分)
下一篇:Git的详细使用(上传到github)

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月12日 02时03分01秒