UID192389
帖子
精華
主題
積分26826
現金
積極性
威望
違規
熱心
推廣次數
閱讀權限30
註冊時間2009-8-29
在線時間 小時
最後登錄1970-1-1
TA的每日心情 | 怒 2017-1-18 12:17 AM |
---|
簽到天數: 512 天 連續簽到: 1 天 [LV.9]以壇為家II
|
發表於 2013-3-27 20:28:39
|
顯示全部樓層
fantasy83115 發表於 2013-3-27 07:42 PM
程式設計, 有人看得懂嗎 哈哈 - int main() {
- int totalInput = 0 ; // 幾組數據
- scanf( "%d", & totalInput ) ;
-
- int nowHeight = 0 ; // 當前路面高度
- int nowHeightMax = 0 ; // 當前最大路面高度
- int totalAqua = 0 ; // 當前積水格數
- for ( int i = 0 ; i < totalInput ; i ++ ) {
- scanf( "%d", & nowHeight ) ;
- if ( nowHeightMax < nowHeight )
- nowHeightMax = nowHeight ;
- totalAqua += nowHeightMax - nowHeight ;
- } // for
-
- printf( "積水總共 %d 格", totalAqua ) ;
- } // main()
複製代碼 |
|