Advertisement
Infiniti_Inter

max of length index

Mar 13th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int INF = 1e9 + 13;
  6.  
  7. int main(){
  8.     ifstream in("input.txt");
  9.     int Max_length = -INF;
  10.     int answer = -1;
  11.     int cur_index = 0;
  12.     while(in.peek() != EOF)
  13.     {
  14.         cur_index++;
  15.         string s;
  16.         getline(in, s);
  17.         if (int(s.length()) > Max_length)
  18.         {
  19.             Max_length = s.length();
  20.             answer = cur_index;
  21.         }
  22.     }
  23.     cout << answer;
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement