[轉錄][轉錄][C++] 上機考 (1)

看板NTUBIME100HW作者 (Pineapple)時間18年前 (2007/12/11 08:03), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ [本文轉錄自 NTUBIME99-HW 看板] 作者: matrixjimmy (Jimmy) 看板: NTUBIME99-HW 標題: [轉錄][C++] 上機考 (1) 時間: Sun Dec 17 14:47:55 2006 ※ [本文轉錄自 NTUBIME97-HW 看板] 作者: ychia (12/13~17 生機週!!) 看板: NTUBIME97-HW 標題: [C++] 上機考 (1) 時間: Wed Dec 8 00:20:55 2004 #include <iostream> using std::cout; using std::cin; using std::endl; int main() { const int days = 31; // 八月有三十一天 int t[ days ] = { 0 }; // default to zero long int sum_t = 0; // the sum of temperature int max, min; // max and min temperature // input for ( int counter = 0; counter < days; counter++ ) { cout << "請輸入 8 月 " << counter << " 號的氣溫: "; cin >> t[ counter ]; } // max, min must have a given initial value max = t[ 0 ]; min = t[ 0 ]; // calculate sum, find maximum and minimum temperature for ( int i = 0; i < days; i++ ) { sum_t = sum_t + t[ i ]; // add every element value of t if( t[ i ] > max ) max = t[ i ]; if( t[ i ] < min ) min = t[ i ]; } // calculate and print average, max, min cout << "平均溫度: " << sum_t / days << " 度" << endl; cout << "最高溫度: " << max << " 度" << endl; cout << "最低溫度: " << min << " 度" << endl; return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.22.100 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.62.101.203

12/17 14:52,
嗚...害我打了兩篇>_<...算了..反正我很閒..雖然c++還沒交..
12/17 14:52
-- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.241.52
文章代碼(AID): #17NTFSQ9 (NTUBIME100HW)