当前位置:网站首页>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;
}
边栏推荐
- Advanced learning of MySQL -- basics -- multi table query -- joint query
- Dell笔记本周期性闪屏故障
- . Bytecode structure of class file
- [Niuke classic question 01] bit operation
- Leetcode(547)——省份数量
- 第四篇,STM32中断控制编程
- Advantages and disadvantages of code cloning
- 【JokerのZYNQ7020】AXI_ EMC。
- 【批处理DOS-CMD命令-汇总和小结】-查看或修改文件属性(ATTRIB),查看、修改文件关联类型(assoc、ftype)
- View remote test data and records anytime, anywhere -- ipehub2 and ipemotion app
猜你喜欢
【JVM调优实战100例】05——方法区调优实战(下)
Learn to use code to generate beautiful interface documents!!!
【批处理DOS-CMD命令-汇总和小结】-跳转、循环、条件命令(goto、errorlevel、if、for[读取、切分、提取字符串]、)cmd命令错误汇总,cmd错误
[yolov5 6.0 | 6.1 deploy tensorrt to torch serve] environment construction | model transformation | engine model deployment (detailed packet file writing method)
学习使用代码生成美观的接口文档!!!
Installation and testing of pyflink
ZYNQ移植uCOSIII
UI控件Telerik UI for WinForms新主题——VS2022启发式主题
深度学习之环境配置 jupyter notebook
深度学习之线性代数
随机推荐
【JokerのZYNQ7020】AXI_ EMC。
ActiveReportsJS 3.1中文版|||ActiveReportsJS 3.1英文版
String comparison in batch file - string comparison in batch file
深度学习简史(一)
【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
from . cv2 import * ImportError: libGL. so. 1: cannot open shared object file: No such file or direc
Set (generic & list & Set & custom sort)
Part IV: STM32 interrupt control programming
筑梦数字时代,城链科技战略峰会西安站顺利落幕
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
windows安装mysql8(5分钟)
Advanced learning of MySQL -- basics -- basic operation of transactions
[HFCTF2020]BabyUpload session解析引擎
界面控件DevExpress WinForms皮肤编辑器的这个补丁,你了解了吗?
Advanced learning of MySQL -- Fundamentals -- four characteristics of transactions
Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
Equals() and hashcode()
【批处理DOS-CMD命令-汇总和小结】-跳转、循环、条件命令(goto、errorlevel、if、for[读取、切分、提取字符串]、)cmd命令错误汇总,cmd错误
Dell Notebook Periodic Flash Screen Fault
以机房B级建设标准满足等保2.0三级要求 | 混合云基础设施