Habsburg

prvi

Apr 20th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int N = 0;
  7.     do {
  8.         cout << "Upisite N: ";
  9.         cin >> N;
  10.     }while(N <= 0 || N >= 20);
  11.    
  12.     string polje[N];
  13.    
  14.     int max = 0;
  15.     int pos = 0;
  16.    
  17.     for(int i = 0; i < N; ++i) {
  18.         cout << "Upisite " << i+1 << ". rijec: ";
  19.         cin >> polje[i];
  20.        
  21.         if(polje[i].length() > max) {
  22.             max = polje[i].length();
  23.         } else {
  24.             if(polje[i].length() >= polje[pos].length())
  25.                 pos = i;
  26.         }
  27.     }
  28.    
  29.     cout << polje[pos];
  30. }
Advertisement
Add Comment
Please, Sign In to add comment