#include <iostream>
using namespace std;
int main(){
int n;
// 输出一行字符串
cout << "Please enter a number:\n";
// 输入一个整数,并赋值给n
cin >> n;
// 输出n
cout << n;
return 0;
}
1.2 输入n个数并把其存入数组中
#include<iostream>usingnamespace std;intmain(){int n;
cout <<"Please enter the number of elements\n";
cin >> n;int a[n];
cout <<"enter"<< n <<"number\n";// 输入n个数 for(int i =0;i<n;i++){
cin >> a[i];}// 遍历数组 for(int i =0;i<n;i++){
cout << a[i];}return0;}
#include<iostream>#include<sstream>intmain(){
std::stringstream ss;int number =123;
ss <<"The number is: "<< number;
std::string result = ss.str();
std::cout << result;return0;}