找回密碼
 註冊
搜索
熱搜: 活動 交友 discuz
查看: 1892|回覆: 0

[原創] 陣列 最大小值

[複製鏈接]
發表於 2007-6-8 10:43:07 | 顯示全部樓層 |閲讀模式
  1. #include<iostream>
  2. using namespace std ;

  3. int Total=5,TempInt=0 ;

  4. void FindMin(int Min[])
  5. {
  6.     for(int i=0;i<=Total;i++)
  7.     {
  8.         if( Min[i] < TempInt )
  9.         {
  10.             TempInt = Min[i] ;
  11.         }
  12.     }   
  13. }

  14. void FindMax(int Max[])
  15. {
  16.     for(int i=0;i<=Total;i++)
  17.     {
  18.         if( Max[i] > TempInt )
  19.         {
  20.             TempInt = Max[i] ;
  21.         }
  22.     }   
  23. }

  24. int main()
  25. {
  26.     int Matrix[Total] ;
  27.    
  28.     for(int i = 0;i<=Total;i++)
  29.     {
  30.         cout << "Matrix[" << (i+1) << "] = " ;
  31.         cin >> Matrix[i] ;
  32.     }
  33.         
  34.     FindMax(Matrix) ;
  35.     cout << endl << "Max = " << TempInt ;   
  36.    
  37.     FindMin(Matrix) ;     
  38.     cout << endl << "Min = " << TempInt ;
  39.    
  40.     cout << endl ;
  41.     system("PAUSE") ;
  42.     return 0 ;   
  43. }
複製代碼
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Checking the Pageranks

Archiver|手機版|小黑屋|WEO

GMT+8, 2026-7-30 12:01 AM , Processed in 0.045279 second(s), 18 queries .

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表