当前位置:网站首页>Haut OJ 1352: string of choice
Haut OJ 1352: string of choice
2022-07-05 05:17:00 【hunziHang】
Problem description :
Choice Like to convert consecutive and identical characters into characters and numbers , And the number she expressed is one , such as ”c22” Namely ”ccccc”, That is, each number represents the number of times to repeat the last most recent character . You can Choice Restore the written string ?
Input :
Enter an integer in the first line T, Represents the number of test groups .
Each set of data includes a row , Enter a Choice Write string , The length is less than 100( No number will appear in the first place )
Output :
Each group outputs one line , Represents the expanded string .
The sample input :
1 a3b4c22
Sample output :
aaaabbbbbccccc
Cause analysis :
Multiple instances Pay attention to whether line wrapping is required ( Generally ), It's definitely wrong not to change lines .
Solution :
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--)
{
char c;
string str;
int num,i,j,k;
cin>>str;
k=str.length();
for(i=0;i<k;i++)
{
if(str[i]>='0'&&str[i]<='9')
{
num=str[i]-'0';
for(j=1;j<=num;j++)
cout<<c;
}
else
{
c=str[i];
cout<<c;
}
}
cout<<endl;
}
return 0;
}
边栏推荐
- 2022/7/1 learning summary
- [turn]: OSGi specification in simple terms
- Basic knowledge points
- UE 虚幻引擎,项目结构
- Download xftp7 and xshell7 (official website)
- [转]MySQL操作实战(一):关键字 & 函数
- C # perspective following
- [interval problem] 435 Non overlapping interval
- Data is stored in the form of table
- 支持多模多态 GBase 8c数据库持续创新重磅升级
猜你喜欢

Unity check whether the two objects have obstacles by ray

C语言杂谈1

Generate filled text and pictures

2022年上半年国家教师资格证考试

【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research

To the distance we have been looking for -- film review of "flying house journey"

Django reports an error when connecting to the database. What is the reason

嵌入式数据库开发编程(零)

Unity find the coordinates of a point on the circle

嵌入式数据库开发编程(六)——C API
随机推荐
Romance of programmers on Valentine's Day
cocos_ Lua listview loads too much data
Grail layout and double wing layout
Leetcode word search (backtracking method)
嵌入式数据库开发编程(零)
Cocos create Jiugongge pictures
Kali 2018 full image download
[turn to] MySQL operation practice (III): table connection
When will Wei Lai, who has been watched by public opinion, start to "build high-rise buildings" again?
[allocation problem] 135 Distribute candy
TF-A中的工具介绍
2022年上半年国家教师资格证考试
Basic knowledge points of dictionary
Unity synergy
2022/7/1學習總結
Unity shot tracking object
Unity sends messages and blocks indecent words
Quick sort summary
质量体系建设之路的分分合合
一个新的微型ORM开源框架