Facebook
From rak, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 276
  1. #include "stdafx.h"
  2. #include "iostream"
  3. using namespace std;
  4.  
  5. int IleRazy(char napis[], char znak)
  6. {
  7.         int wynik = 0;
  8.         int i = 0;
  9.         while (napis[i] != '\0')
  10.         {
  11.                 if (napis[i] == znak)
  12.                 {
  13.                         wynik++;
  14.                 }
  15.                 i++;
  16.         }
  17.         return wynik;
  18. }
  19.  
  20. int _tmain(int argc, _TCHAR* argv[])
  21. {
  22.         /*
  23.         int i;
  24.         const int rozmiar1 = 10;
  25.         char napis1[rozmiar1];
  26.         const int rozmiar2 = 30;
  27.         char napis2[rozmiar2];
  28.         const int rozmiar3 = 30;
  29.         char napis3[rozmiar3];
  30.         cout << "Podaj imie: ";
  31.         cin >> napis1;
  32.         cout << "Imie: " << napis1 << endl;
  33.         cout << "Podaj imie i nazwisko: ";
  34.         fflush(stdin);
  35.         cin.getline(napis2, rozmiar2);
  36.         cout << "Imie i nazwisko: " << napis2 << endl;
  37.         cout << "podaj miasto: ";
  38.         fflush(stdin); // czyszczenie bufora
  39.         cin >> napis3;
  40.         cout << "miasto: " << napis3 << endl;
  41.         i = 0;
  42.         while (napis3[i] != '\0')
  43.         {
  44.                 cout << napis3[i] << endl;
  45.                 i++;
  46.         }
  47.         */
  48.         const int rozmiar4 = 10;
  49.         char napis4[rozmiar4];
  50.         cout << "podaj napis: ";
  51.         cin >> napis4;
  52.         cout <<"znak a wystepuje: " << IleRazy(napis4, 'a') << endl;
  53.         system("pause");
  54.         return 0;
  55. }
  56.  
  57.