Advertisement
Daniel_leinaD

5.1

Jun 9th, 2022
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <sstream>
  5. using namespace std;
  6.  
  7. void metod(string x) {
  8.     istringstream ss(x);
  9.     string small, tmp;
  10.     ss >> small;
  11.     string big = small;
  12.     while (ss >> tmp){
  13.         if (tmp.size() < small.size())
  14.             small = tmp;
  15.         if (tmp.size() > big.size())
  16.             big = tmp;
  17.     }
  18.     cout << "Длинное: " << big << " " << '\t' << '\n';
  19.     cout << "Короткое: " << small <<" " << '\t' << '\n';
  20. }
  21. int main() {
  22.     setlocale(LC_ALL, "ru");
  23.     string str;
  24.     while (str != "end") { // ввод строк, пока не будет *end*
  25.         if (str == "end"){
  26.           break;
  27.         }
  28.         else{
  29.           getline(cin, str);
  30.           metod(str);
  31.       }
  32.  
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement