Advertisement
KingaGolas

zad25

Mar 30th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int wystapienia (int n, int c)
  6. {
  7.  
  8. int s=0;
  9. for (int i=0; n>0; i++)
  10. {
  11. if (n%10==c)
  12. {
  13. s++;
  14. }
  15. n=n/10;
  16. }
  17. return s;
  18. }
  19.  
  20. int main()
  21. {
  22. cout << wystapienia (100,0) << endl;
  23. cout << wystapienia (5822792,2) << endl;
  24. cout << wystapienia (102111,1) << endl;
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement