/*
https://www.hackerrank.com/challenges/30-data-types/problem
*You have to use 'getline(cin, string)' to get a whole line. (not 'cin >> string')
However, you've already used 'cin' on the previous line. 'cin' left '\n' in the buffer, so your next 'getline' would get just a '\n'.
so use
getline(cin>>ws, string)
to consume the whitespace or newline.
*To express fixed point,
cout << fixed << setprecision(1);
*/
// Declare second integer, double, and String variables.
int ii;
double dd;
string ss;
// Read and save an integer, double, and String to your variables.
cin >> ii;
cin >> dd;
getline(cin >> ws, ss);
// Note: If you have trouble reading the entire string, please go back and review the Tutorial closely.
// Print the sum of both integer variables on a new line.
cout << ii + i << endl;
// Print the sum of the double variables on a new line.
cout << fixed << setprecision(1);
cout << dd + d << endl;
// Concatenate and print the String variables on a new line
cout << s + ss << endl;
// The 's' variable above should be printed first.
댓글 없음:
댓글 쓰기