当前位置:网站首页>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;
}
边栏推荐
- Equals() and hashcode()
- tensorflow 1.14指定gpu运行设置
- 5种不同的代码相似性检测,以及代码相似性检测的发展趋势
- String comparison in batch file - string comparison in batch file
- Dell笔记本周期性闪屏故障
- Slam d'attention: un slam visuel monoculaire appris de l'attention humaine
- build. How to configure the dependent version number in the gradle file
- ZYNQ移植uCOSIII
- Provincial and urban level three coordinate boundary data CSV to JSON
- 学习光线跟踪一样的自3D表征Ego3RT
猜你喜欢

Part 7: STM32 serial communication programming

Stm32f407 ------- SPI communication

省市区三级坐标边界数据csv转JSON
深入探索编译插桩技术(四、ASM 探秘)

Deep learning environment configuration jupyter notebook

学习光线跟踪一样的自3D表征Ego3RT

【JVM调优实战100例】05——方法区调优实战(下)

Telerik UI 2022 R2 SP1 Retail-Not Crack

筑梦数字时代,城链科技战略峰会西安站顺利落幕

Equals() and hashcode()
随机推荐
深度学习之线性代数
mongodb客户端操作(MongoRepository)
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
[force buckle]41 Missing first positive number
Three methods to realize JS asynchronous loading
pyflink的安装和测试
Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
What is time
省市区三级坐标边界数据csv转JSON
What kind of experience is it to realize real-time collaboration in jupyter
【JokerのZYNQ7020】AXI_ EMC。
【批处理DOS-CMD命令-汇总和小结】-跳转、循环、条件命令(goto、errorlevel、if、for[读取、切分、提取字符串]、)cmd命令错误汇总,cmd错误
C9 colleges and universities, doctoral students make a statement of nature!
Advanced learning of MySQL -- basics -- basic operation of transactions
build. How to configure the dependent version number in the gradle file
How do novices get started and learn PostgreSQL?
Levels - UE5中的暴雨效果
【软件逆向-自动化】逆向工具大全
[HFCTF2020]BabyUpload session解析引擎
Alexnet experiment encounters: loss Nan, train ACC 0.100, test ACC 0.100