我要讓用戶輸入他想要輸入的浮點數。一旦輸入浮動數字,我要輸入一條消息,指出類似「最大數字輸入是如此「。如何從用戶輸入打印最大數字
如何識別用戶輸入的最大號碼。
#include <stdio.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float count;
float input;
float large;
cout << "Enter the number of floating numbers you wish to input: ";
scanf("%f", &count);
do
{
cin >> input;
count--;
}
while(0 < count);
return 0;
}
沒你教練覆蓋'if'語句和比較操作的基本知識? –
他確實覆蓋了if語句。我試過了它的多種變體,但我不確定是否將if語句包含在do-while循環或do while循環之外。我試着讓變量最大,以便我可以把最大=輸入;但每次用戶放置其浮動號碼時都會覆蓋該值。這基本上不是我想要完成的 – Jane
這不是一個編碼服務,除非你自己做,否則你不會學習。相反,你需要做些什麼,解釋你期望它應該做什麼,解釋它沒有達到預期的效果,並且提出具體的問題來解決這個特定的問題。 –