c++如何打印由这样的字符组成的图形?

king 2020 2007-06-22 02:52:23
stststststststststs
ststststststststs
stststststststs
ststststststs
stststststs
ststststs
stststs
ststs
sts
s
...全文
805 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
juicee 2007-06-23
  • 打赏
  • 举报
回复
楼主要厚道点
juicee 2007-06-23
  • 打赏
  • 举报
回复
为什么上面那段代码和我贴的几乎一样?然后我贴的不见了?。。。。
king 2020 2007-06-22
  • 打赏
  • 举报
回复
我是这样解决的,但是为什么每次都是我提问再自己解决,分白白送人?奇怪啊!
#include<iostream>
using namespace std;
void main()
{

for(int i=1;i<=10;i++){
for(int j=1;j<=i-1;j++)
cout<<" ";
for(int k=1;k<=21-2*i;k++){
if (k % 2!=0)
cout<<"s";
else
cout<<"t";
}
cout<<endl;
}

}
king 2020 2007-06-22
  • 打赏
  • 举报
回复
谢谢各位,可惜钱能的书上这题还没讲到数组,所以不能用数组.
sunfred 2007-06-22
  • 打赏
  • 举报
回复
楼上的好人啊,其实自己注意循环,就可以实现
isarc 2007-06-22
  • 打赏
  • 举报
回复
拿去用吧,还可以简化的,自己做吧。
#include "stdafx.h"

int _tmain(int argc, _TCHAR* argv[])
{
int spacenum = 0;
char a[] = "ststststststststststststststs";
int vcount = 28;
for (int i = 0; i < 15; i++)
{
printf("%*s\n",29 + i, a);
if (vcount > 1)
{
a[vcount] = ' ';
a[vcount - 1] = ' ';
vcount -= 2;
}

}
system("pause");
return 0;
}
isarc 2007-06-22
  • 打赏
  • 举报
回复
for(int i = 0; i < n; i++)
{
print(,空格个数,数组内容);
数组最后面的ts换成空格;
空格个数+++;
}
isarc 2007-06-22
  • 打赏
  • 举报
回复
for(int i = 0; i < n; i++)
{
print(,空格个数,数组内容);
数组最后面的ts换成空格;
}
juicee 2007-06-22
  • 打赏
  • 举报
回复
p
king 2020 2007-06-22
  • 打赏
  • 举报
回复
我知道是循环,问题是st这两个字母怎么变化的啊?
huashizhixin 2007-06-22
  • 打赏
  • 举报
回复
循环解决问题
不难
  • 打赏
  • 举报
回复
........
这个几个循环就能搞定的事情啊

33,311

社区成员

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

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