このコードを実行すると、ユーザー入力の高さによって異なる右揃えのピラミッドの結果が得られます。しかし、私はCS50チェック機能を実行すると、それは次のように私に告げる:CS50 Mario Pyramid - コードは機能しますが、check50を実行するとエラーが発生します
:(予想される出力\正しく1 の高さを処理ではなく、「##の\ n」は
は:(高さを扱います2正しく 予想される出力\ではなく、 "## \ nは### \ n" は
が:(23正しく 予想される出力\ではなく、 "##の\ nは..."
の高さを処理します:(高さ24を拒否し、次に高さ2 \を受け取ります。 "## \ n ### \ n"
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height;
int row;
int space;
int hash;
// declare variables
do
{
printf("Height:\n");
height = GetInt();
}
while (height < 0 || height > 23);
// build pyaramid if acceptable height entered
for (row = 0; row < height; row++)
{
for (space = 0; space < (height - row); space++)
{
printf(" ");
}
for (hash = 0; hash < 2 + row; hash++)
{
printf("#");
}
printf("\n");
}
}
ああ、あなたはちょうど正しい - 私はそれが問題であることを認識しました。お返事をありがとうございます! – user6923745