当前位置:网站首页>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);
}边栏推荐
- [lvgl layout] grid layout
- String问题
- Use the root user to create a new user and set the password for
- tensorflow boolean_mask函数
- Don't care too much about others' eyes, it will erase your glory
- [audio decoding chip] Application of vs1503 audio decoding chip
- XXL execute node error log swiping
- 别太在意别人的眼光,那会抹杀你的光彩
- Redis 哨兵机制
- Accumulation of project problems
猜你喜欢

渗透学习-SQL注入篇-靶场篇-安全狗的安装与绕过实验(后续还会更新)

Practice of online problem feedback module (12): realize image deletion function

【C语言】操作符详解(深入理解+整理归类)

创建WPF项目

Jinan renshe has signed 1w+ electronic labor contract, which greatly helps HR digitalization
![[wechat applet] understand conditional rendering, list rendering and wxss template style](/img/97/cb78efcbcfe1a598da87751c482a98.png)
[wechat applet] understand conditional rendering, list rendering and wxss template style

Redis.conf details
![[lvgl layout] grid layout](/img/36/47f586f3dc1a114ed7775c4e190872.png)
[lvgl layout] grid layout

一个AI玩41个游戏,谷歌最新多游戏决策Transformer综合表现分是DQN的两倍

Create WPF project
随机推荐
你是谁由你自己决定!
Redis.conf details
[learning notes] Web page rendering process
STM32 MP3 music player based on FatFs r0.14b & SD card (also a simple application of FatFs)
Who you are is up to you!
String question
JS and TS learning summary
Redis基本类型-结合Set
STM32外部中断(寄存器版本)
10分钟就能写出来的——25~30K的国外企业招聘面试考题,这不是轻轻松松吗~
[USB voltmeter and ammeter] Based on stm32f103c8t6 for Arduino
An AI plays 41 games, and the comprehensive performance score of Google's latest multi game decision transformer is twice that of dqn
HashSet转数组
MGR_mysqlsh_keepalive高可用架构部署文档
Identification of Chinese medicinal materials
Redis.conf详解
[waveform / signal generator] Based on stc1524k32s4 for C on Keil
xxl执行节点错误日志刷屏
Redis 持久化
2022-07-22 mysql/stonedb parallel hashjoin memory usage analysis