程序打印一个三角形的星号 [英] program to print a triangle of astericks

查看:117
本文介绍了程序打印一个三角形的星号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以在这里用C编写一个程序,仅用于循环播放

打印以下输出


*

***

*****

*******

*********

***********


我试过但只能得到一方的三角形...


快速回复表示赞赏。谢谢,

解决方案

这是我的代码


#include< stdio.h>

int main()

{

int i,j,k;


for( i = 1; i <= 8; i ++)

{

for(j = 7; j> = 1; j--)

printf("");


{for(k = 1; k< = i; k = k + 1)

printf(" ; *");

printf(" \ n");}


}

}

请帮我找到错误的地方。谢谢,

Vishnu




VISHNU VARDHAN REDDY UNDYALA写道:

这是我的代码

#include< stdio.h>
int main()
{i /,i,j,k;

for(i = 1; i <= 8; i ++)
{
for(j = 7; j> = 1; j--)
printf("" );

{for(k = 1; k< = i; k = k + 1)
printf(" *");
printf(" \\ \\ n \\ n}}}

}
}
请帮我找到错误的地方。谢谢,
Vishnu




您还需要在开始打印星星之前打印适当数量的空格字符。

你打印星星,但它总是一样的

星数。此外,您的图像显示如下星级:1 3 5 7 ...从使用步骤2的一个开始

。此程序不会这样做。


hiiii,

可以帮你写代码

请发给我代码

这是非常紧急的对我来说,我知道我必须做间距

但是我不能保持这个循环

i等我4个回复

thanx

vishnu


Hi,
Could anyone over here, write a program in C using only for loop to
print the following output

*
***
*****
*******
*********
***********

I tried but could only get one side of the triangle...

Quick reply is appreciated. Thanks,

解决方案

this is my code

#include<stdio.h>
int main()
{
int i,j,k;

for(i=1 ; i<=8 ; i++)
{
for (j=7 ; j>=1 ; j--)
printf(" ");

{for(k=1 ; k<=i ; k=k+1)
printf("*");
printf("\n");}

}
}
please help me in finding where I did wrong. Thanks,
Vishnu



VISHNU VARDHAN REDDY UNDYALA wrote:

this is my code

#include<stdio.h>
int main()
{
int i,j,k;

for(i=1 ; i<=8 ; i++)
{
for (j=7 ; j>=1 ; j--)
printf(" ");

{for(k=1 ; k<=i ; k=k+1)
printf("*");
printf("\n");}

}
}
please help me in finding where I did wrong. Thanks,
Vishnu



You also need to print the apropriate amount of space characters before
you start printing stars. You do print stars, but it''s always the same
number of stars. Also, your image shows stars like: 1 3 5 7... starting
from one using step 2. This program doesn''t do that.


hiiii,
can u help in writing tha code
please send me tha code
it is very urgent to me i know i have to do spacing
but i can''t maintaining tha loops for that
i am waiting 4 ur reply
thanx
vishnu


这篇关于程序打印一个三角形的星号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆