Asterisk printing1
• Write a program that outputs a triangle with a '*' character
• Input the Height repeatedly using the While statement
• Output a '*' character using the For statement
int height;
while( true )
{
printf("Height: ");
if( 1 == scanf("%d",&height) )
{
for( int i = 0;i < height;++i)
{
for(int j = 0; j <= i;++j)
printf("*");
printf("\n");
}
printf(">>>=====================RESTART=====================");
}
else
fflush(stdin);
}
height = 8
for( int i = 0;i < height;++i)
{
for(int j = 0; j <= i;++j)
printf("*");
printf("\n");
}
#include<stdio.h>
void main(){
int h = 0;
int i = 0;
int j = 0;
scanf("%d",&h);
//打印h行
for(i = 0; i < h ; i ++){
//每行打印i+1个*
for(j = 0; j < i + 1 ; j ++ ){
printf("*");
}
printf("\n");
}
}
#include
void main(){
int h = 0;
int i = 0;
int j = 0;
scanf("%d",&h);
//打印h行
for(i = 0; i < h ; i ++){
//每行打印i+1个*
for(j = 0; j < i + 1 ; j ++ ){
printf("*");
}
printf("\n");
}
}
#include
void main(){
int h = 0;
int i = 0;
int j = 0;
scanf("%d",&h);
//打印h行
for(i = 0; i < h ; i ++){
//每行打印i+1个*
for(j = 0; j < i + 1 ; j ++ ){
printf("*");
}
printf("\n");
}
}