【例131】空格分隔输出读入一个字符一个整数一个单精度浮点数一个双精度浮点数然后按顺序输出它们并且要求在他们之间用一个空格分隔。输出浮点数时保留6位小数。【输入】第一行是一个字符;n第二行是一个整数;n第三行是一个单精度浮点数;n第四行是一个双精度浮点数。【输出】输出字符整数单精度浮点数和双精度浮点数之间用空格分隔请用c++代码写出
#include <iostream>
#include <iomanip> // for setprecision
int main() {
char ch;
int num;
float f;
double d;
std::cin >> ch;
std::cin >> num;
std::cin >> f;
std::cin >> d;
std::cout << ch << " " << num << " " << std::fixed << std::setprecision(6) << f << " " << std::fixed << std::setprecision(6) << d << std::endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/ijsc 著作权归作者所有。请勿转载和采集!