Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <fstream>
- using namespace std;
- int main () {
- ifstream in;
- in.open("input.txt");
- string s, ans;
- ans = "";
- while (in >> s)
- {
- int i = 0;
- string word = "";
- while (i < s.length())
- {
- if (s[i] == ',' || s[i] == '.' || s[i] == '!' || s[i] == '?'
- && word.length() > ans.length())
- {
- ans = word;
- }
- else
- {
- word = word + s[i];
- }
- i++;
- }
- if (word.length() > ans.length())
- {
- ans = word;
- }
- }
- in.close();
- ofstream out;
- out.open("output.txt");
- out << ans << endl;
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement