这道题不让用cin、cout、get、put,怎么改呀?
使用输出流的方式输出小数并保留至特定小数位时,可以通过在待输出的浮点型变量前添加<<std::fixed << std::setprecision(x) << 来实现,其中x是一个代表小数位数的整数。
使用这种方法来输出需要用到 iomanip 库。
#include<iomanip>
int a;
long long b;
float c;
double d;
char e;
char f[32];
int main(){
std::cin >> a >> b >> c >> d >> e >> f;
std::cout << "a = " << a << " ";
std::cout << "b is " << b << '\n';
std::cout << "c equals" << std::fixed << std::setprecision(6) << c;
std::cout << "and d equals " << std::fixed << std::setprecision(12) << d << std::endl;
std::cout << e << " is e" << "\n";
std::cout << "f = " << f << std::endl;
return 0;
}```