SHARE
TWEET

Value and position of maximal number.

LazySenpai Jan 12th, 2017 (edited) 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Zimplementuj program ktory w wektorze o max. 50 elementach znajdzie element max i okresli jego polozenie
  2. #include <iostream>
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. int main()
  8. {
  9.     int max, t[50], polozenie=1, n;
  10.  
  11.     cout << "Program znajedzie max i okresli jego polozenie" << endl
  12.          << "Podaj ile elementow chcesz wprowadzic : ";
  13.     cin  >> n;
  14.  
  15.     for(int x=0; x<n; x++)
  16.     {
  17.         cout << "Podaj " << x+1 << " liczbe : ";
  18.         cin >> t[x];
  19.  
  20.         if(x==0)
  21.             max=t[x];
  22.  
  23.         else if(t[x]>max)
  24.         {
  25.             max=t[x];
  26.             polozenie=x+1;
  27.         }
  28.     }
  29.  
  30.     cout << "MAKSYMALNA = " << max << endl;
  31.     cout << "POLOZENIE = " << polozenie << endl;
  32.  
  33.     cin.get();
  34.     cin.get();
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top