NeoYang 發表於 2007-6-8 10:43:07

陣列 最大小值

#include<iostream>
using namespace std ;

int Total=5,TempInt=0 ;

void FindMin(int Min[])
{
    for(int i=0;i<=Total;i++)
    {
      if( Min < TempInt )
      {
            TempInt = Min ;
      }
    }   
}

void FindMax(int Max[])
{
    for(int i=0;i<=Total;i++)
    {
      if( Max > TempInt )
      {
            TempInt = Max ;
      }
    }   
}

int main()
{
    int Matrix ;
   
    for(int i = 0;i<=Total;i++)
    {
      cout << "Matrix[" << (i+1) << "] = " ;
      cin >> Matrix ;
    }
      
    FindMax(Matrix) ;
    cout << endl << "Max = " << TempInt ;   
   
    FindMin(Matrix) ;   
    cout << endl << "Min = " << TempInt ;
   
    cout << endl ;
    system("PAUSE") ;
    return 0 ;   
}
頁: [1]
查看完整版本: 陣列 最大小值

Checking the Pageranks