Advertisement
Aodai

Untitled

Mar 19th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. char str[255];
  8. int charAnt = 0;
  9. int cifre = 0, numere = 0;
  10. std::cin >> str;
  11.  
  12. for (int i = 0; i < strlen(str); i++) {
  13. if (i == 0)
  14. if (isdigit(str[i]) > 0) {
  15. cifre++;
  16. charAnt++;
  17. }
  18. else {
  19. if (isdigit(str[i - 1]) > 0)
  20. {
  21. cifre++;
  22. charAnt++;
  23. }
  24. else {
  25. numere++;
  26. charAnt = 0;
  27. }
  28. }
  29. }
  30. std::cout << cifre << std::endl << numere;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement