当前位置:网站首页>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;
}
边栏推荐
- Generate filled text and pictures
- What is the agile proportion of PMP Exam? Dispel doubts
- Embedded database development programming (zero)
- Use of snippets in vscode (code template)
- [binary search] 34 Find the first and last positions of elements in a sorted array
- Cocos create Jiugongge pictures
- Listview pull-down loading function
- 远程升级怕截胡?详解FOTA安全升级
- [turn to] MySQL operation practice (I): Keywords & functions
- [leetcode] integer inversion [7]
猜你喜欢

Research on the value of background repeat of background tiling

Redis has four methods for checking big keys, which are necessary for optimization

Generate filled text and pictures

Leetcode word search (backtracking method)

Unity ugui source code graphic

Recherche de mots pour leetcode (solution rétrospective)
![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)
[speed pointer] 142 circular linked list II

Establish cloth effect in 10 seconds

LeetCode之單詞搜索(回溯法求解)

嵌入式数据库开发编程(五)——DQL
随机推荐
小程序直播+电商,想做新零售电商就用它吧!
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
[turn]: Apache Felix framework configuration properties
UE fantasy engine, project structure
The next key of win generates the timestamp file of the current day
2022/7/1学习总结
Listview pull-down loading function
TF-A中的工具介绍
[interval problem] 435 Non overlapping interval
Embedded database development programming (zero)
【ES实战】ES上的native realm安全方式使用
Solon Auth 认证框架使用演示(更简单的认证框架)
Cocos2dx Lua registers the touch event and detects whether the click coordinates are within the specified area
Simple modal box
2022/7/2做题总结
Use the command character to close the keyboard command of the notebook
GameObject class and transform class of unity
Data is stored in the form of table
Count sort
django连接数据库报错,这是什么原因