#include<iostream>
using namespace std;
#include<string>
int main()
{ //1、整形
int a = 0;
cout << "请给整形变量a赋值:" << endl;
cin >> a;
cout << "整形变量a=" << a << endl;
//2、浮点型
float f = 3.14;
cout << "请给浮点型变量f赋值:" << endl;
cin >> f;
cout << "浮点型变量a=" << f << endl;
//3、字符型
char ch = 'b';
cout << "请给字符型变量ch赋值:" << endl;
cin >> ch;
cout << "字符型变量ch=" << ch << endl;
//4、字符串型
string str = "hello";
cout << "请给字符串str赋值:" << endl;
cin >>str;
cout << "整形变量str=" <<str << endl;
//5、布尔数据类型
bool flag = false;
cout << "请给布尔类型flag赋值:" << endl;
cin >> flag;
cout << "布尔类型flag=" << flag << endl;
system("pause");
return 0;
}
【数据的输入】
于 2022-04-22 16:23:34 首次发布