当前位置:网站首页>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;
}
边栏推荐
- 建立自己的网站(17)
- New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML
- Advanced learning of MySQL -- basics -- multi table query -- external connection
- 浅谈测试开发怎么入门,如何提升?
- BFS realizes breadth first traversal of adjacency matrix (with examples)
- 随时随地查看远程试验数据与记录——IPEhub2与IPEmotion APP
- Mongodb client operation (mongorepository)
- Pytorch中torch和torchvision的安装
- Deep understanding of distributed cache design
- Chapter II proxy and cookies of urllib Library
猜你喜欢

windows安装mysql8(5分钟)
![[user defined type] structure, union, enumeration](/img/a5/d6bcfb128ff6c64f9d18ac4c209210.jpg)
[user defined type] structure, union, enumeration

Learn self 3D representation like ray tracing ego3rt

学习光线跟踪一样的自3D表征Ego3RT
![[C language] dynamic address book](/img/e7/ca1030a1099fe1f59f5d8dd722fdb7.jpg)
[C language] dynamic address book

【JVM调优实战100例】04——方法区调优实战(上)
![[software reverse automation] complete collection of reverse tools](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[software reverse automation] complete collection of reverse tools

「精致店主理人」青年创业孵化营·首期顺德场圆满结束!

建立自己的网站(17)

Stm32f407 ------- DAC digital to analog conversion
随机推荐
重上吹麻滩——段芝堂创始人翟立冬游记
Advanced learning of MySQL -- Fundamentals -- four characteristics of transactions
筑梦数字时代,城链科技战略峰会西安站顺利落幕
Summary of being a microservice R & D Engineer in the past year
Address information parsing in one line of code
How do novices get started and learn PostgreSQL?
Advanced learning of MySQL -- basics -- multi table query -- self join
build. How to configure the dependent version number in the gradle file
How to get started and improve test development?
深度学习之线性代数
深入探索编译插桩技术(四、ASM 探秘)
Link sharing of STM32 development materials
【批处理DOS-CMD命令-汇总和小结】-查看或修改文件属性(ATTRIB),查看、修改文件关联类型(assoc、ftype)
通过串口实现printf函数,中断实现串口数据接收
STM32开发资料链接分享
threejs图片变形放大全屏动画js特效
Learning notes 5: ram and ROM
深度学习之数据处理
Pytorch中torch和torchvision的安装
Telerik UI 2022 R2 SP1 Retail-Not Crack