每5个输出换一行

a266328633 2012-07-01 06:36:56
代码怎么写?
...全文
820 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
白衣渡江 2012-07-01
  • 打赏
  • 举报
回复
#include<iostream>
using namespace std;

int main()
{
for(int i=0; i<n; i++)
{
cout<<i<<"";
if((i+1)/5 == 0
{
cout<<endl;
}
}

return 0;
}

这样应该可以吧
W170532934 2012-07-01
  • 打赏
  • 举报
回复
换行方式多了去啊。楼上给了几个了。我也提供个。
for(i=0;i<n;i++)
{
for(j=0;j<5;j++)
cout<<j<< " ";
cout<<endl;
}

cbzjzsb123 2012-07-01
  • 打赏
  • 举报
回复
#include <iostream>
using namespace std;

int main()
{
for( int i = 0; i < 20; ++i )
{
cout << i;
if( i > 0 && (i+1) % 5 == 0 )
cout << endl;
else
cout << "\t";
}
return 0;
}
CandPointer 2012-07-01
  • 打赏
  • 举报
回复
if 0==mod(n,5)
printf \n
end
zjs100901 2012-07-01
  • 打赏
  • 举报
回复
#include <iostream>
using namespace std;

int main()
{
for( int i = 0; i < 20; ++i )
{
cout << i;
if( i > 0 && (i+1) % 5 == 0 )
cout << endl;
else
cout << "\t";
}
return 0;
}

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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