首先我要推銷這個 bits/stdc++.h 函式庫 ( #include <bits/stdc++.h>
)
它可以幫助你用 C 的程式碼享受 C++ 的快感
for (int i = 0; i < people; i++) printf("%d ", vscore[i]);
printf("\n");
for (int i = 0; i < people; i++)
{
if (vscore[i] < 60 && vscore[i] > best) best = vscore[i];
}
if (best != -1) printf("%d\n", best);
else printf("best case\n");
for (int i = 0; i < people; i++)
{
if (vscore[i] >= 60 && vscore[i] < worst) worst = vscore[i];
}
if (best != 101) printf("%d\n", worst);
else printf("worst case\n");
關鍵在於第二次判斷的 >=
判斷時記得,不然他會對於 60 分不聞不問