Advertisement
Vla_DOS

Untitled

Feb 8th, 2023
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void Print(string* arr, int size) {
  8.     for (int i = 0; i < size; i++) {
  9.         cout << arr[i] << endl;
  10.     }
  11. }
  12.  
  13. void Dobutok(string* a, int size) {
  14.     string MinElement;
  15.     int MinLenght = _I32_MAX;
  16.  
  17.     for (int i = 0; i < size; i++) {
  18.         if (a[i].length() < MinLenght) {
  19.             MinElement = a[i];
  20.             MinLenght = a[i].length();
  21.         }
  22.     }
  23.  
  24.     string MaxElement;
  25.     int MaxLenght = 0;
  26.  
  27.     for (int i = 0; i < size; i++) {
  28.         if (a[i].length() > MaxLenght) {
  29.             MaxElement = a[i];
  30.             MaxLenght = a[i].length();
  31.         }
  32.     }
  33.     cout << "MinElement: " << MinElement << endl;
  34.     cout << "MaxElement: " << MaxElement << endl;
  35.     cout << "Dobutok: " << MaxLenght * MinLenght << endl;
  36. }
  37.  
  38. int main() {
  39.     const int size = 9;
  40.     string a[size] = { "qw", "wer", "tyut", "bnmnbgb", "ghfg", "/.gf", "fdgfd", "gv", "sdf" };
  41.  
  42.     Print(a, size);
  43.     cout << endl;
  44.  
  45.     Dobutok(a, size);
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement