Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a,b;
- int wystapienia(int n,int c)
- {
- int a,b=0,d=0;
- do
- {
- a=n%10;
- if(a==c)
- {
- d=d+1;
- }
- else{}
- b=b+a;
- n=n/10;
- }
- while(n!=0);
- return d;
- }
- int main()
- {
- int a,b;
- cout<<"Liczba: "<<endl;
- cin>>a;
- do
- {
- cout<<"Cyfra: "<<endl;
- cin>>b;
- }
- while(b>9);
- cout<<"Cyfra pojawiła się: " << wystapienia(a,b) << "razy" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement