前言
首先,如果看过我前面的文章的同学,因该知道如何输出吧,有出,必有入,今天便来学习如何输入内容。
实战
在C++中,输入将用关键字cin,如下图:
#include <iostream>
using namespace std;
int main(){
int n;
cout << "input:";
cin >> n;
cout << n << endl;
return 0;
}
直接看第六行代码>>表示将输入内容存放进整数类型变量n中,结果:
input:5
5
恭喜你,学会了C++输入。
(没人知道我水了一篇文章,哈哈)