私は C の初心者です。King 2nd Edition による最新の C プログラミングへのアプローチを使用しています。
第 6 章で行き詰っています。 問題 1: ユーザーが入力した一連の数値の最大値を見つけるプログラムを作成してください。プログラムは、ユーザーに数字を 1 つずつ入力するように求める必要があります。ユーザーが 0 または負の数を入力すると、プログラムは入力された最大の負でない数を表示する必要があります。
これまでのところ、私は持っています:
#include <stdio.h>
int main(void)
{
float a, max, b;
for (a == max; a != 0; a++) {
printf("Enter number:");
scanf("%f", &a);
}
printf("Largest non negative number: %f", max);
return 0;
}
質問の最後の部分、つまりループのユーザー入力の最後でどの負でない数が最大であるかを確認する方法がわかりません。
max = a > a ???
ご協力いただきありがとうございます!