Advertisement
JoannaDobrowolska

Zadanie 25

Mar 31st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int WYSTAPIENIA (int n, int c);
  6.  
  7. int main()
  8. {
  9.     int n,c;
  10.     cout << "Podaj liczbe" << endl;
  11.     cin>>n;
  12.     cout <<"Podaj cyfre ktorej ilosc w liczbie chcesz sprawdzic"<<endl;
  13.     cin>>c;
  14.     cout<< WYSTAPIENIA (n,c);
  15.     return 0;
  16. }
  17.  
  18. int WYSTAPIENIA (int n, int c){
  19. int a;
  20. a=0;
  21. do{
  22.     if(n%10==c){
  23.     a++;}
  24.        n=n/10;
  25.     }
  26.  
  27.    while(n>0);
  28. return a;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement