Leedwon

Untitled

Apr 27th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. // 12-2
  2.  
  3. #include "String2.h"
  4. #include <cstring>
  5. #include <cctype>
  6. using namespace std;
  7. int main()
  8. {
  9.     String s1(" i ucze sie C++.");
  10.     String s2 = "Podaj swoje imie: ";
  11.     String s3;
  12.     cout << s2;
  13.     cin >> s3;
  14.     s2 = "Mam na imie: " + s3;
  15.     cout << s2 << ".\n";
  16.     s2 = s2 + s1;
  17.     s2.stringUp();
  18.     cout << "Ciag\n" << s2 << "\nzawiera " << s2.howMany('A') << " 'A'.\n";
  19.     s1 = "czerwona";
  20.     String rgb[3] = { String(s1), String("zielona"), String("niebieska") };
  21.     String ans;
  22.     cout << "Podaj nazwe barwy podstawowej: ";
  23.     bool success = false;
  24.     while (cin >> ans)
  25.     {
  26.         ans.stringLow();
  27.         for (int i = 0; i < 3; i++)
  28.         {
  29.             if (ans == rgb[i])
  30.             {
  31.                 cout << "Prawidlowo!\n";
  32.                 success = true;
  33.                 break;
  34.             }
  35.             if (success)
  36.                 break;
  37.             else
  38.                 cout << "Sprobuj ponownie!\n";
  39.         }
  40.     }
  41.     cout << "Zegnam\n";
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment