当前位置:网站首页>Design a function print to print the string. If only the string parameter s is passed, the string length is compared with 10, greater than 10, print the first 10 characters, less than 10, and output a
Design a function print to print the string. If only the string parameter s is passed, the string length is compared with 10, greater than 10, print the first 10 characters, less than 10, and output a
2022-07-24 07:01:00 【Mo xiaodai ^o^】
#include <iostream>
#include <string>
using namespace std;
void print(string s)
{
cout << " The first one is :" << endl;
if (s.length() > 10)
cout << s.substr(0, 10) << endl;
else
cout << s << endl;
}
void print(string s, int n)
{
cout << " The second kind :" << endl;
if (s.length() > n)
cout << s.substr(0, n) << endl;
else
cout << s << endl;
}
void main()
{
string s;
cout << " Please enter the characters :";
cin >> s;
int n;
cout << "n=";
cin >> n;
print(s);
print(s, n);
}边栏推荐
- [audio decoding chip] Application of vs1503 audio decoding chip
- OWASP TOP10 penetration test
- MapReduce(一)
- Camera Hal OEM模块 ---- cmr_grab.c
- MGR_ mysqlsh_ Keepalive high availability architecture deployment document
- mysql获取自增行标(区别mysql版本)
- Redis分布式缓存学习笔记
- Mac can't connect to local MySQL server through socket '/tmp/mysql Sock '(2) problem
- 先爱自己,再爱别人。
- [media controller] open source project learning notes (based on Arduino micro development board)
猜你喜欢
![[learning notes] Web page rendering process](/img/29/3f419f5851dac1194a94a59635846f.png)
[learning notes] Web page rendering process

Geek planet ByteDance one stop data governance solution and platform architecture
![[lvgl] [stage summary 1]](/img/39/c6e96ae7971a2350769ef5b5950f8f.png)
[lvgl] [stage summary 1]

Sparksql core usage, 220724,
![[USB voltmeter and ammeter] Based on stm32f103c8t6 for Arduino](/img/5f/40e4e144a628ef1aa38ab536b40366.png)
[USB voltmeter and ammeter] Based on stm32f103c8t6 for Arduino

MGR_ mysqlsh_ Keepalive high availability architecture deployment document

Jinan renshe has signed 1w+ electronic labor contract, which greatly helps HR digitalization

"Big factory interview" JVM Chapter 21 questions and answers

Getting started with redis

《大厂面试》之JVM篇21问与答
随机推荐
PostgreSQL date handler usage
ADB interaction - kill the ugly default shell interface
[lvgl (2)]
使用root用户为创建新用户并设置密码
metaRTC5.0实现君正的纯C的webrtc版IPC
数据分析思维之从整体出发分析零售行业——全方位多方面细节分析
Jsonobject is sorted in A-Z order of key
[learning notes] see the difference between a+++a and a+a++ from the compilation
Redis基本类型-结合Set
STM32基于hal库的adc以DMA的多通道采样以及所遇问题解决
Create WPF project
sojson jsjiami.com. V6 crawler JS reverse
【学习笔记】Web页面渲染的流程
Record the pits encountered in the deserialization of phpserializer tool class
mysql自动生成创建时间和更新时间
lambda表达式对list对象进行多字段排序
Getting started with redis
[media controller] open source project learning notes (based on Arduino micro development board)
Redis data type - list list
Redis 持久化