当前位置:网站首页>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;
}
边栏推荐
- UE4/UE5 虚幻引擎,材质篇(三),不同距离的材质优化
- Under the national teacher qualification certificate in the first half of 2022
- Insert sort
- Double pointer Foundation
- [merge array] 88 merge two ordered arrays
- cocos2dx_ Lua card flip
- Unity get component
- Solon 框架如何方便获取每个请求的响应时间?
- Unity intelligent NPC production -- pre judgment walking (method 1)
- PMP考生,请查收7月PMP考试注意事项
猜你喜欢
Unity ugui source code graphic
django连接数据库报错,这是什么原因
Applet live + e-commerce, if you want to be a new retail e-commerce, use it!
UE fantasy engine, project structure
Bucket sort
Simple modal box
Optimization scheme of win10 virtual machine cluster
服务熔断 Hystrix
Recherche de mots pour leetcode (solution rétrospective)
嵌入式数据库开发编程(零)
随机推荐
[binary search] 69 Square root of X
Basic knowledge points of dictionary
[speed pointer] 142 circular linked list II
Page countdown
2022/7/1学习总结
Time format conversion
[interval problem] 435 Non overlapping interval
xftp7与xshell7下载(官网)
Kali 2018 full image download
Unity card flipping effect
Merge sort
[轉]: OSGI規範 深入淺出
Embedded database development programming (zero)
Out and ref functions of unity
Development error notes
Panel panel of UI
Programmers' experience of delivering takeout
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research
C language Essay 1
Chinese notes of unit particle system particle effect