#include <stdio.h>
#include <cs50.h>
int main(void)
{
int height, row, spaces, hashes; //declare all variables to be used
do //prompt the user for valid height inputs that are non-negative and less than 23.
{
printf("Height:");
height = get_int();
} while ((height < 0) || (height > 23));
for (row = 1; row <= height; row ++) // iterate through each row of the height
{
for (spaces = (height - row); spaces >= 0; spaces--) //print the number of spaces for the ith row
{
printf(" ");
}
for (hashes = (row + 1); hashes <= (height + 1); hashes++) //print the number of hashes for each row
{
printf("#");
}
printf("\n");
}
}
私は上記のコードで何が欠けているのか分かりません。空白は期待どおりに印刷されますが、ハッシュの動作は反転され、最高と最低が印刷されます。CS50 Mario Pyramid in C - コードロジックによって期待どおりに出力されないハッシュ
[Mario Style Pyramidを作成する]の可能な複製(http://stackoverflow.com/questions/38961481/creating-a-mario-style-ピラミッド) – Pharaoh