控制输出精度,为什么只有y输出 ,而X不输出 ,求解 !!

weixin_36747231 2017-01-06 09:35:58




#include "stdafx.h"
#include<iostream>
#include<iomanip>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int x=123;
double y=3.1415;
cout<<"x=";
cout.width(10);
cout<<"x=";
cout<<"y=";
cout.width(10);
cout<<y<<endl;
cout.fill('*');
cout.precision(4);
cout.setf(ios::showpos);
cout<<"x=";
cout.width(10);
cout<<"x=";
cout<<"y=";
cout.width(10);
cout<<y<<endl;

return 0;
}
+++++++++++++++++++++++++

...全文
72 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccrun.com 2017-01-06
  • 打赏
  • 举报
回复
输出X你需要这样:
cout << x << std::endl;

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧