AcWing 2066. 解码
原题链接
简单
作者:
哈基咪
,
2020-10-14 16:01:06
,
所有人可见
,
阅读 395
//
// main.cpp
// 十一届蓝桥杯解码
//
// Created by 魏浩洋 on 2020/7/16.
// Copyright ? 2020 魏浩洋. All rights reserved.
//
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
string res;
char last_char;
bool judge_char(char a)
{
if((a>='a'&&a<='z')||(a>='A'&&a<='Z')) return true;
else return false;
}
bool judge_num(char a)
{
if(a>='0'&&a<='9')
return true;
else return false;
}
int char_to_num(char a)
{
int num=a-'0';
return num;
}
int main()
{
string str;
cin>>str;
last_char=str[0];
res.push_back(str[0]);
for(int i=1;i<str.length();i++)
{
if(judge_num(str[i])&&judge_char(last_char))
{
int a=char_to_num(str[i])-1;
while(a--)
{
res.push_back(last_char);
}
last_char=str[i];
}
if(judge_char(str[i]))
{
res.push_back(str[i]);
last_char=str[i];
}
}
cout<<res<<endl;
return 0;
}