输出问题

sbellson 2008-03-11 09:33:49
请问如何在C++中输出0001,同时可以完成++或--运算,谢谢!
...全文
109 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mr__zhang 2008-03-12
  • 打赏
  • 举报
回复
可不可以把题目说清楚些啊,呵呵
sbellson 2008-03-12
  • 打赏
  • 举报
回复
谢谢,实验中
hastings 2008-03-12
  • 打赏
  • 举报
回复
int main()
{
char c=cout.fill('0');
for(int i(0);i<10000;++i)
{
cout.width(4);
cout<<i<<' ';
}
cout<<'\n';
cout.fill(c);
return 0;
}
野男孩 2008-03-12
  • 打赏
  • 举报
回复
fill(0)...
jieao111 2008-03-12
  • 打赏
  • 举报
回复

不好意思..更正一下

int i=0
while(1)
{cout<<0<<0<<0<<++i<<endl;
if(i>9)
cout<<0<<0<<++i<<endl;
else if(i>99)
cout<<0<<++i<<endl;
else if(i<9999&&i>999)
cout<<++i<<endl;
else
cout<<"error"
}
jieao111 2008-03-12
  • 打赏
  • 举报
回复

int i=0;
cout<<0<<0<<0<<i++;
if(i>9)
cout<<0<<0<<i++;
else if(i>99)
cout<<0<<i++;
else if(i<9999&&i>999)
cout<<i++;
else
cout<<"error"
沙漠里的海豚 2008-03-12
  • 打赏
  • 举报
回复
printf("%04d\n",number);
这样就可以了,试试看吧
sbellson 2008-03-12
  • 打赏
  • 举报
回复
要弄个银行的排队单据输出,初始值为0001,最大值9999,值可以累加.谢谢!
HelloDan 2008-03-12
  • 打赏
  • 举报
回复
输出格式问题,前面的补0吗?
dubiousway 2008-03-11
  • 打赏
  • 举报
回复
不太明白意思,这样:?


#include <iostream>
using namespace std;

void main(){
int i=1;
cout<<i<<i<<i<<i--<<endl;
}

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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