Advertisement
Dizzy3113

Untitled

Nov 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. void s(int n, int c, int &k)
  5. {
  6. k=0;
  7. while(n)
  8. {
  9. if(n%10>=c-1 && n%10<=c+1)
  10. k++;
  11. n=n/10;
  12. }
  13. }
  14. int main()
  15. {
  16. int n=650, c=3, k;
  17. s(n,c,k);
  18. cout<<k;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement