私が作業しているプログラムは、その数字の辺が等しいシンボルの直角三角形を出力します。 0を入力すると終了します。それ以外の場合は、新しい入力を再度要求する必要があります。その数字の辺が等しいシンボルの直角三角形
私はあなたが0を入力した場合にそれを終了させることができますか、そうでなければ別の入力を求めますか?私はおそらくwhileループを使用する必要があることを知っています。しかし、どうすれば変更できますか?
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char s; /*s is symbol (the input)*/
int a, b, n; /*n is number of rows (the input)*/
printf("Please type the symbol of the triangle:...\n"); /*Ask for symbol input*/
scanf_s("%c", &s, 1);
printf("Please type a positive non-zero number between 5 and 35:...\n"); /*Ask for number of rows input*/
scanf_s("%d", &n);
assert(n >= 5 && n <= 35);
for (a = 1; a <= n; a++) /*How many rows to display+create*/
{
for (b = 1; b <= a; b++)
{
printf("%c", s);
}
printf("\n");
}
system("PAUSE");
}
だから私の質問は、「あなたは0を入力すると終了する方法を、それ以外の場合は、再び新しい入力をお願いします。」ということです私は、私はおそらく、whileループを使用する必要があります知っている 。しかし、私はそれをどのように変更するのですか? –
コメントに質問しないでください。代わりに、実際の質問に含めてください。 – Laurel