Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. struct Osoba
  2. {
  3. public:
  4.     string imie;
  5.     string nazwisko;
  6.     string data_urodzenia;
  7.     string inicjaly;
  8.  
  9.     void GenerujInicjaly()
  10.     {
  11.         inicjaly = "";
  12.         inicjaly += (char)imie[0];
  13.         inicjaly += '.';
  14.         inicjaly += (char)nazwisko[0];
  15.         inicjaly += '.';
  16.     }
  17. };
  18.  
  19. void Zadanie_2()
  20. {
  21.     Osoba Ja;
  22.     cout << "Podaj imie: ";
  23.     cin >> Ja.imie;
  24.     cout << "Podaj nazwisko: ";
  25.     cin >> Ja.nazwisko;
  26.     Ja.GenerujInicjaly();
  27.     cout << "Podaj date urodzenia (BEZ SPACJI): ";
  28.     cin >> Ja.data_urodzenia;
  29.     int dlugosc_nazwiska = Ja.nazwisko.length(), dlugosc_imienia = Ja.imie.length(); //dlugosc imienia i nazwiska
  30.  
  31.     string samogloski = "EYUIOA";
  32.     int samogloski_imie = 0, samogloski_nazwisko = 0;
  33.     string szyfrowane_imie = Ja.imie, szyfrowane_nazwisko = Ja.nazwisko;
  34.  
  35.     //licz samogloski dla imienia i szyfruj je
  36.     for (size_t i = 0; i < Ja.imie.length(); i++)
  37.         for (size_t a = 0; a < samogloski.length(); a++)
  38.             if (toupper(Ja.imie[i]) == samogloski[a]) {
  39.                 samogloski_imie++;
  40.                 szyfrowane_imie[i] = '*';
  41.             }
  42.     //i nazwisko
  43.     for (size_t i = 0; i < Ja.nazwisko.length(); i++)
  44.         for (size_t a = 0; a < samogloski.length(); a++)
  45.             if (toupper(Ja.nazwisko[i]) == samogloski[a]) {
  46.                 samogloski_nazwisko++;
  47.                 szyfrowane_nazwisko[i] = '*';
  48.             }
  49.  
  50.     //wypisanie danych
  51.     cout << endl << endl << "Imie: " << Ja.imie << endl << "Nazwisko: " << Ja.nazwisko << endl;
  52.     cout << "Dlugosc imienia/nazwiska i samoglosek w imieniu/nazwisku: " << dlugosc_imienia << "/" << dlugosc_nazwiska << ", " << samogloski_imie << "/" << samogloski_nazwisko << endl;
  53.     cout << "Zaszyfrowane imie i nazwisko: " << szyfrowane_imie << " " << szyfrowane_nazwisko << endl;
  54.     cout << "Inicjaly: " << Ja.inicjaly << ", data urodzenia: " << Ja.data_urodzenia << endl << endl;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement