求10 個整數中最大值

2021-08-28 10:14:07 字數 564 閱讀 9056

題目:求10 個整數中最大值

分析:可以預設第乙個數為最大,用max儲存最大數字,然後每輸入乙個數字,就與max進行比較,不斷更新max的值。最後max中儲存的值就是最大數字。這裡10個整數可以不用陣列儲存,逐一輸入比較;也可以用陣列儲存,然後遍歷比較。

#define _crt_secure_no_warnings 1

#include#includeint main()

} while (count < 10);

printf("max=%d\n", max);

//求十個整數中的最大值:陣列儲存

int a[10] = ;

int maxid = 0;//maxid記錄最大數字的下標值,先另第乙個數字為最大

//將輸入的10個數字存入陣列中

for (int i = 0; i < 10; i++) }

printf("max=%d\n", a[maxid]);

system("pause");

return 0;

}

求10 個整數中最大值。

求10 個整數中最大值。define crt secure no warnings include int main max a 0 for i 0 i 10 i else printf 這十個整數的最大值是 d n max system pause 程式設計思路 首先從鍵入十個整數 由於數值較多,...

C語言 求10 個整數中最大值

求10個整數中的最大值。先建立乙個能夠儲存10個資料的陣列,輸入資料,將第乙個值賦給變數max,然後依次將陣列中的每乙個數與max比較,當max小於對應的數時,則將對應的數賦給max,10個值全部執行完畢之後,max中便是這是個值中最大的值,輸出max即可。define crt secure no ...

Problem A 求個最大值

time limit 1 sec memory limit 128 mb submit 1635 solved 1339 submit status web board 定義maxvalue類,用於求一系列非零整數的最大值。其中 1.資料成員elements用於儲存所有輸入的非零整數。3.int g...