Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- void main()
- {
- int maxlength=0, currlength=0;
- char c, str[10000], strmax[10000];
- int i=0, num=0;
- fstream f("in.txt");
- while(!f.eof())
- {
- f.get(c);
- if(c!='\n')
- {
- str[currlength]=c;
- currlength++;
- //cout<<c<<'_'<<currlength;
- if(str[currlength-1]=='.' || f.eof())
- {
- cout<<"PHRASE["<<num<<"] LENGTH = "<<currlength<<endl;
- for(i=0; i<currlength; i++)
- {
- cout<<str[i];
- }
- cout<<endl;
- num++;
- if(currlength>maxlength)
- {
- maxlength=currlength;
- for(i=0; i<currlength; i++)
- {
- strmax[i]=str[i];
- str[i]=0;
- }
- //cout<<"!!!!!!";
- }
- currlength=0;
- }
- }
- }
- cout<<"MAXSTRING(LENGTH = "<<maxlength<< "):"<<endl;
- for(i=0; i<maxlength; i++)
- cout<<strmax[i];
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement