napisać program, żeby wyświetlało piramidę złożoną z #
Kod: Zaznacz cały
##
###
####
####
Siedzę długo nad tym, jestem bardzo blisko, wiem, że będą pętle, znam początek i koniec programu, estetykę itp. Jakby mi ktoś pomógł to bym to lepiej zrozumiał. Dziękuję.
Wymyśliłem coś takiego, ale nie wychodzi:
1.
Kod: Zaznacz cały
#include <stdio.h>
int main (void)
{
int height;
printf("please enter a positive integer no more than 23:")
scanf("%i", &height);
while(height > 23|height <=0)
{
printf("please enter a positive integer no more than 23:")
scanf("%i", &height);
}
for ( int y= 9- height; y<height;y++)
{
printf(" ");
}
for ( int x= 9- height; x<height;x++)
{
printf("#");
}
printf("
");
return 0;
}
Kod: Zaznacz cały
#include <stdio.h>
int main (void)
{
int height;
printf("please enter a positive integer no more than 23:")
scanf("%i", &height);
while(height > 23|height <=0)
{
printf("please enter a positive integer no more than 23:")
scanf("%i", &height);
}
for ( int y= 9- height; y<height;y++)
{
printf(" ");
printf("#");
printf("
");
height= (height-1);
}
return 0;
}