Advertisement
LukaszPanko

Zadanie 25

Mar 29th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int WYSTAPIENIA(int l, int c)
  6. {
  7.    int i=0;
  8.    int a=0;
  9.     for(;l>1;i++){
  10.         if(l%10==c){
  11.                 a++;
  12.             }
  13.        l=l/10;
  14.     }
  15.     return a;
  16. }
  17.  
  18. int main()
  19. {
  20.     int liczba;
  21.     int cyfra;
  22.     cout << "Podaj liczbe: ";
  23.     cin>>liczba;
  24.     cout<<"Podaj cyfre: ";
  25.     cin>>cyfra;
  26.     cout<<"Cyfra "<<cyfra<<" pojawia sie w liczbie "<<liczba<<" ";
  27.     cout<<WYSTAPIENIA(liczba,cyfra)<<" razy";
  28.  
  29.  
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement