Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void s(int n, int c, int &k)
- {
- k=0;
- while(n)
- {
- if(n%10>=c-1 && n%10<=c+1)
- k++;
- n=n/10;
- }
- }
- int main()
- {
- int n=650, c=3, k;
- s(n,c,k);
- cout<<k;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement