当前位置:网站首页>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;
}
边栏推荐
- Unity enables mobile phone vibration
- TF-A中的工具介绍
- Es module and commonjs learning notes
- Django reports an error when connecting to the database. What is the reason
- Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
- Lua determines whether the current time is the time of the day
- Merge sort
- GBase数据库助力湾区数字金融发展
- 使用命令符关闭笔记本自带键盘命令
- 2022 / 7 / 1 Résumé de l'étude
猜你喜欢
Bucket sort
Leetcode word search (backtracking method)
对象的序列化
C language Essay 1
一个新的微型ORM开源框架
Use of snippets in vscode (code template)
Optimization scheme of win10 virtual machine cluster
Merge sort
National teacher qualification examination in the first half of 2022
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
随机推荐
用 Jmeter 工具做个小型压力测试
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
The difference between heap and stack
Collapse of adjacent vertical outer margins
cocos2dx_ Lua particle system
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
[allocation problem] 135 Distribute candy
To the distance we have been looking for -- film review of "flying house journey"
嵌入式数据库开发编程(零)
[转]MySQL操作实战(一):关键字 & 函数
C # perspective following
Optimization scheme of win10 virtual machine cluster
对象的序列化
Research on the value of background repeat of background tiling
PMP candidates, please check the precautions for PMP examination in July
2022/7/2 question summary
Unity find the coordinates of a point on the circle
The next key of win generates the timestamp file of the current day
嵌入式数据库开发编程(五)——DQL
[转]MySQL操作实战(三):表联结