当前位置:网站首页>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;
}
边栏推荐
- Configuring the stub area of OSPF for Huawei devices
- Chapter 5 DML data operation
- Cause of handler memory leak
- 【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
- Pytorch中torch和torchvision的安装
- 深度学习之线性代数
- 浅谈测试开发怎么入门,如何提升?
- Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
- Chenglian premium products has completed the first step to enter the international capital market by taking shares in halber international
- Five different code similarity detection and the development trend of code similarity detection
猜你喜欢
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
[user defined type] structure, union, enumeration
Chapter II proxy and cookies of urllib Library
Provincial and urban level three coordinate boundary data CSV to JSON
建立自己的网站(17)
[牛客] [NOIP2015]跳石头
重上吹麻滩——段芝堂创始人翟立冬游记
Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version
threejs图片变形放大全屏动画js特效
【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
随机推荐
深度学习简史(一)
Advanced learning of MySQL -- basics -- multi table query -- subquery
.class文件的字节码结构
. Bytecode structure of class file
Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
Attention SLAM:一种从人类注意中学习的视觉单目SLAM
How to get started and improve test development?
Dell筆記本周期性閃屏故障
[HFCTF2020]BabyUpload session解析引擎
Installation and testing of pyflink
第七篇,STM32串口通信编程
Configuring OSPF basic functions for Huawei devices
【批處理DOS-CMD命令-匯總和小結】-字符串搜索、查找、篩選命令(find、findstr),Find和findstr的區別和辨析
学习光线跟踪一样的自3D表征Ego3RT
C Primer Plus Chapter 14 (structure and other data forms)
Trace tool for MySQL further implementation plan
建立自己的网站(17)
再聊聊我常用的15个数据源网站
Deep learning framework TF installation
[force buckle]41 Missing first positive number