Advertisement
hopingsteam

Untitled

Mar 29th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. char s[101] = "Reprezentat cu 4 zecimale PI este 13.1415 si e este 2.7182";
  9.  
  10. char rez[101] = "";
  11. char *cuvant = strtok(s, ".");
  12. while(cuvant != NULL)
  13. {
  14. //cout << cuvant << "\n";
  15. int i1 = strlen(cuvant) - 1;
  16. while(cuvant[i1] >= '0' && cuvant[i1] <= '9')
  17. i1--;
  18.  
  19. int i2 = 0;
  20. while(cuvant[i2] >= '0' && cuvant[i2] <= '9')
  21. i2++;
  22.  
  23. //cout << i1 << " " << i2 << " ";
  24.  
  25. cuvant[i1] = '\0';
  26. strcat(rez, cuvant+i2);
  27. cuvant = strtok(NULL, ".");
  28. }
  29. cout << rez;
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement