问题描述
- c语言新手 求大神帮忙
-
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("
");
}
printf(">>>=====================RESTART=====================");
}
else
fflush(stdin);
}
解决方案三:
height = 8
for( int i = 0;i < height;++i)
{
for(int j = 0; j <= i;++j)
printf("*");
printf("
");
}
解决方案四:
#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("
");
}
}
解决方案五:
#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("
");
}
}
解决方案六:
#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("
");
}
}