Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int N = 0;
- do {
- cout << "Upisite N: ";
- cin >> N;
- }while(N <= 0 || N >= 20);
- string polje[N];
- int max = 0;
- int pos = 0;
- for(int i = 0; i < N; ++i) {
- cout << "Upisite " << i+1 << ". rijec: ";
- cin >> polje[i];
- if(polje[i].length() > max) {
- max = polje[i].length();
- } else {
- if(polje[i].length() >= polje[pos].length())
- pos = i;
- }
- }
- cout << polje[pos];
- }
Advertisement
Add Comment
Please, Sign In to add comment