当前位置:网站首页>Daily summary of code knowledge
Daily summary of code knowledge
2022-06-30 04:08:00 【Elvin Yuwen】
stay C++ Can be used in
getline(cin,s1);
To input a string , frequently-used cin Input mode You cannot enter a string containing embedded spaces
cin Display by entering English name
Code display :
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main( )
{
string name, age, sex;
// getline(cin, name);
// getline(cin, age);
// getline(cin, sex);
cin >> name;
cin >> age;
cin >> sex;
cout << name << endl;
cout << age << endl;
cout << sex << endl;
return 0;
}Output results :
simth elvin
10
simth
elvin
10
--------------------------------
Process exited after 16.51 seconds with return value 0
Please press any key to continue . . .
but getline Of C++ Function can read the whole line , Including leading and embedded spaces , And store it in a string object .
getline Method input English name
Code display :
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main( )
{
string name, age, sex;
getline(cin, name);
getline(cin, age);
getline(cin, sex);
// cin >> name;
// cin >> age;
// cin >> sex;
cout << name << endl;
cout << age << endl;
cout << sex << endl;
return 0;
}
Output results ;
Simth elvin
10
man
Simth elvin
10
man
--------------------------------
Process exited after 28.29 seconds with return value 0
Please press any key to continue . . .
边栏推荐
- ThingsBoard教程(二三):在规则链中计算二个设备的温度差
- Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column
- . Net 7 JWT configuration is too convenient!
- [note] on May 27, 2022, MySQL is operated through pychart
- Knowledge - how to build rapport in sales with 3 simple skills
- How to use Jersey to get the complete rest request body- How to get full REST request body using Jersey?
- Linear interpolation of spectral response function
- Titanic(POJ2361)
- Everyone, Flink 1.13.6, mysql-cdc2.2.0, the datetime (6) class extracted
- Idea grey screen problem
猜你喜欢

Thingsboard tutorial (II and III): calculating the temperature difference between two devices in a regular chain

Linear interpolation of spectral response function

Node red series (28): communication with Siemens PLC based on OPC UA node

基于海康EhomeDemo工具排查公网部署出现的视频播放异常问题

华为云原生——数据开发与DataFactory
![[note] May 23, 2022 MySQL](/img/a1/dd71610236729e1d25c4c3e903c0e0.png)
[note] May 23, 2022 MySQL
![[summary of skimming questions] database questions are summarized by knowledge points (continuous update / simple and medium questions have been completed)](/img/89/fc02ce355c99031623175c9f351790.jpg)
[summary of skimming questions] database questions are summarized by knowledge points (continuous update / simple and medium questions have been completed)

The jupyter notebook kernel hangs up frequently and needs to be restarted

How to use FME to create your own functional software

SQLyog导入数据库时报错,求帮解决!
随机推荐
尝试链接数据库时出现链接超时报错,如何解决?
win10系统使用浏览器下载后,内容无故移动或删除
如何通过进程启动来分析和解决EasyCVR内核端口报错问题?
Geometric objects in shapely
Pytorch Profiler+ Tensorboard + VS Code
Hebb and delta learning rules
云原生——Web实时通信技术之Websocket
Day 9 script and resource management
dotnet-exec 0.5.0 released
工程安全和工程质量
Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column
第十一天 脚本与游戏AI
【论文阅读|深读】DANE:Deep Attributed Network Embedding
Day 10 data saving and loading
Find the interface and add parameters to the form
mysql更新数组形式的json串
Day 11 script and game AI
[note] May 23, 2022 MySQL
Node red series (28): communication with Siemens PLC based on OPC UA node
. Net 7 JWT configuration is too convenient!