首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

浮点数格式化输出怎么消零

2012-03-04 
浮点数格式化输出如何消零?浮点数格式化输出如何消零?如 3.12000,输出为3.123.1000,输出为3.13.0000,输出

浮点数格式化输出如何消零?
浮点数格式化输出如何消零?
如 3.12000,输出为3.12
3.1000,输出为3.1
3.0000,输出为3

[解决办法]

C/C++ code
#include <iostream>#include <stdio.h>int _tmain(int argc, _TCHAR* argv[]){    std::cout << 3.12000 << std::endl;    printf( "%g\n", 3.1200 );    return 0;} 

热点排行