Advertisement
Guest User

CODE#

a guest
Dec 20th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. void main()
  7. {
  8.     int maxlength=0, currlength=0;
  9.     char c, str[10000], strmax[10000];
  10.     int i=0, num=0;
  11.     fstream f("in.txt");
  12.     while(!f.eof())
  13.     {
  14.         f.get(c);
  15.         if(c!='\n')
  16.         {
  17.             str[currlength]=c;
  18.             currlength++;
  19.             //cout<<c<<'_'<<currlength;
  20.  
  21.             if(str[currlength-1]=='.' || f.eof())
  22.             {
  23.                 cout<<"PHRASE["<<num<<"] LENGTH = "<<currlength<<endl;
  24.                 for(i=0; i<currlength; i++)
  25.                 {
  26.                     cout<<str[i];
  27.                 }
  28.  
  29.                 cout<<endl;
  30.                 num++;
  31.  
  32.                 if(currlength>maxlength)
  33.                 {
  34.                     maxlength=currlength;
  35.                     for(i=0; i<currlength; i++)
  36.                     {
  37.                         strmax[i]=str[i];
  38.                         str[i]=0;
  39.                     }
  40.                     //cout<<"!!!!!!";
  41.                 }
  42.  
  43.                 currlength=0;
  44.             }
  45.         }
  46.     }
  47.  
  48.     cout<<"MAXSTRING(LENGTH = "<<maxlength<< "):"<<endl;
  49.  
  50.     for(i=0; i<maxlength; i++)
  51.         cout<<strmax[i];
  52.  
  53.     cout<<endl;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement