หน้าเว็บ

วันพุธที่ 4 กันยายน พ.ศ. 2556

[CPP] หาค่า Max ใน Array 1 มิติ


:::: CODE ::::

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4.  {
  5. int Num[10],max=0; 
  6.  
  7. for (int a=0; a<10; a++) {
  8. cout << "Insert Num#"<<a+1<<" : ";
  9. cin >> Num[a]; 
  10. } 
  11. for(int d=0; d<10; d++)
  12. { 
  13. if (Num[d]>max) 
  14. max=Num[d];
  15. } 
  16. cout<<endl <<"Max Is "<< max <<endl;
  17. return(0);
  18.  }