首页 > 其他 > 详细

PTA乙级 (*1084 外观数列 (20分)(int转换成string:to_string))

时间:2020-02-04 21:12:00      阅读:80      评论:0      收藏:0      [点我收藏+]

1084 外观数列 (20分)

https://pintia.cn/problem-sets/994805260223102976/problems/994805260583813120

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
int main()
{
	string s1;
	int n;
	cin>>s1>>n;
	for(int i=0;i<n-1;i++)
	{
		string s2;
		int count[10]={0};
		for(int j=0;j<s1.length();j++)
		{
			count[s1[j]-‘0‘]++;
			if((j==s1.length()-1)||(s1[j]!=s1[j+1]))
			{
				s2+=to_string(s1[j]-‘0‘);
				s2+=to_string(count[s1[j]-‘0‘]);
				count[s1[j]-‘0‘]=0;
			}
		}
		s1=s2;
	}
	cout<<s1;
	return 0;
}

  

PTA乙级 (*1084 外观数列 (20分)(int转换成string:to_string))

原文:https://www.cnblogs.com/jianqiao123/p/12260887.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!