当前位置:网站首页>Openjudge noi 1.7 08: character substitution
Openjudge noi 1.7 08: character substitution
2022-07-07 01:02:00 【Jun Yi_ noip】
【 Topic link 】
OpenJudge NOI 1.7 08: Character substitution
【 Topic test site 】
1. character string
【 Solution code 】
solution 1: Use character array
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s[35], a, b;// character a Replace with b
cin >> s >> a >> b;
int len = strlen(s);
for(int i = 0; i < len; i++)
{
if(s[i] == a)
s[i] = b;
}
cout << s;
return 0;
}
solution 2: Use string class
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
char a, b;// character a Replace with b
cin >> s >> a >> b;
for(int i = 0; i < s.length(); i++)
{
if(s[i] == a)
s[i] = b;
}
cout << s;
return 0;
}
边栏推荐
- Data sharing of the 835 postgraduate entrance examination of software engineering in Hainan University in 23
- Data processing of deep learning
- 【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
- [C language] dynamic address book
- Pytorch中torch和torchvision的安装
- 通过串口实现printf函数,中断实现串口数据接收
- How to get started and improve test development?
- Service asynchronous communication
- Advanced learning of MySQL -- basics -- transactions
- What kind of experience is it to realize real-time collaboration in jupyter
猜你喜欢
Configuring the stub area of OSPF for Huawei devices
城联优品入股浩柏国际进军国际资本市场,已完成第一步
JS+SVG爱心扩散动画js特效
BFS realizes breadth first traversal of adjacency matrix (with examples)
Dr selection of OSPF configuration for Huawei devices
Explain in detail the matrix normalization function normalize() of OpenCV [norm or value range of the scoped matrix (normalization)], and attach norm_ Example code in the case of minmax
动态规划思想《从入门到放弃》
Configuring OSPF basic functions for Huawei devices
Installation and testing of pyflink
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
随机推荐
Telerik UI 2022 R2 SP1 Retail-Not Crack
Summary of being a microservice R & D Engineer in the past year
Deep learning environment configuration jupyter notebook
[software reverse automation] complete collection of reverse tools
【JokerのZYNQ7020】AXI_ EMC。
深度学习之环境配置 jupyter notebook
Levels - UE5中的暴雨效果
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
第七篇,STM32串口通信编程
深度学习框架TF安装
【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
Part IV: STM32 interrupt control programming
Telerik UI 2022 R2 SP1 Retail-Not Crack
新手如何入门学习PostgreSQL?
【JVM调优实战100例】05——方法区调优实战(下)
Configuring OSPF basic functions for Huawei devices
第五篇,STM32系统定时器和通用定时器编程
Advanced learning of MySQL -- basics -- basic operation of transactions
How do novices get started and learn PostgreSQL?
Service asynchronous communication