Advertisement
rotti321

ElinimareNumere

Mar 30th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7. char s[105];
  8. cin.getline(s , 105);
  9. for(int i = 0 ; i < strlen(s) ; ++ i)
  10. if(strchr("0123456789" , s[i]))
  11. {
  12. int j = i + 1 , punct = 0;
  13. while(s[j] && strchr("0123456789." , s[j])){
  14. if(s[j] == '.')
  15. punct = 1;
  16. j ++;
  17. }
  18. if(punct){
  19. char X[105];
  20. strcpy(X , s + j); //eliminare nr zecimal
  21. strcpy(s + i , X);
  22. i --;
  23. }
  24. }
  25. cout << s;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement