源程序:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int oneInt1, oneInt2;
char strArray[20];
string str;
double oneDouble;
char oneChar = 'a';
cout << "输入两个整形值,一个字符,一个字符串和一个浮点值,";
cout << "以空格、Tab键或<Enter>键分隔:"<<endl;
cin >> oneInt1 >> oneInt2 >> oneChar >> strArray >> oneDouble;
str = strArray;
cout << "输入的数据是:" << endl;
cout << "字符串是: " << str << endl
<< "两个整型值分别是: " << oneInt1 << "和 " << oneInt2 << endl
<< "字符是: " << oneChar << " "
<< "浮点值是: " << oneDouble << endl;
system("pause");
return 0;
}
运行结果: