当前位置:网站首页>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;
}
边栏推荐
- The present is a gift from heaven -- a film review of the journey of the soul
- GameObject class and transform class of unity
- [转]MySQL操作实战(三):表联结
- django连接数据库报错,这是什么原因
- SDEI初探-透过事务看本质
- [turn]: OSGi specification in simple terms
- 2022/7/2做题总结
- Lua GBK and UTF8 turn to each other
- win10虚拟机集群优化方案
- Data is stored in the form of table
猜你喜欢
随机推荐
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
The difference between heap and stack
Unity shot tracking object
[binary search] 69 Square root of X
Applet Live + e - commerce, si vous voulez être un nouveau e - commerce de détail, utilisez - le!
Stm32cubemx (8): RTC and RTC wake-up interrupt
Development error notes
GBase数据库助力湾区数字金融发展
Listview pull-down loading function
PR first time
Programmers' experience of delivering takeout
[LeetCode] 整数反转【7】
Bucket sort
C iterator
Cocos progress bar progresstimer
Solon Logging 插件的添加器级别控制和日志器的级别控制
Grail layout and double wing layout
Ue4/ue5 illusory engine, material part (III), material optimization at different distances
质量体系建设之路的分分合合
Binary search basis