Код
C++
#include "iostream"
#include "fstream"
#include "string"
#include "cstring"
#include "vector"
using namespace std;
#define characters ((arr[i][j]>='A' && arr[i][j]<='z') || (arr[i][j]>='0' && arr[i][j]<='9') || arr[i][j]=='-')
#define endOfSentence (arr[i][j]!='.' && arr[i][j]!='?' && arr[i][j]!='!')
int main () {
ifstream in("input.txt");
string sentence = "";
string word = "";
vector <string> arr;
while (!in.eof()) {
string tmp;
getline(in,tmp);
arr.push_back(tmp);
}
string currentWord = "";
for (int i=0;i<arr.size();i++) {
for (int j=0;j<arr[i].size();j++) {
if (arr[i][j] != ' ' && characters) {
currentWord += arr[i][j];
} else {
if (currentWord.size() > word.size()) {
word = currentWord;
}
currentWord = "";
}
}
}
string currentSentence = "";
for (int i=0;i<arr.size();i++) {
for (int j=0;j<arr[i].size();j++) {
if (endOfSentence) {
currentSentence += arr[i][j];
} else {
if (currentSentence.size() > sentence.size()) {
currentSentence += arr[i][j];
sentence = currentSentence;
}
currentSentence = "";
}
}
}
cout << word << endl;
cout << sentence;
return 0;}