题目内容

写出下面程序的执行结果:#include #include #include using namespace std;int main() {double values[] = { 1.23, 35.36};string names[] = { "Zoot", "Jimmy"};for (int i=0;i<2;i++)cout << setiosflags(ios_base::left)<< setw(6) << names[i]<< resetiosflags(ios_base::left)<< setw(10) << values[i] << endl;return 0;}

查看答案
更多问题

写出下面程序的执行结果:#include #include #include using namespace std;int main() {double values[] = { 1.23, 35.36};string names[] = { "Zoot", "Jimmy"};cout<

写出下面程序的执行结果:#include #include #include using namespace std;template inline string toString(const T &v) {ostringstream os;os << v;return os.str();}int main() {string str1 = toString(5);cout << str1 << endl;string str2 = toString(1.2);cout << str2 << endl;return 0;}

通过键盘输入:Type \t字符串后,请写出下面程序的执行结果:#include #include using namespace std;int main() { string line;getline(cin, line, 't'); cout << line << endl;return 0;}

写出下面程序的执行结果:#include #include #include using namespace std;struct SalaryInfo {unsigned id;double salary;};int main() {SalaryInfo employee1 = { 600001, 8000 };ofstream os("payroll", ios_base::out | ios_base::binary);os.write(reinterpret_cast(&employee1), sizeof(employee1));os.close();ifstream is("payroll", ios_base::in | ios_base::binary);if (is) {SalaryInfo employee2;is.read(reinterpret_cast(&employee2), sizeof(employee2));cout << employee2.id << " " << employee2.salary << endl;} else {cout << "ERROR: Cannot open file 'payroll'." << endl;}is.close();return 0;}

答案查题题库