Advertisement
a53

VerifNumar_OF

a53
Oct 16th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int elim[100];
  6.  
  7. int main()
  8. {
  9. char s[101];
  10. cin.getline(s , 101);
  11. int lastzero = -1, amcifrenenule = 0, cnt = 0;
  12. for(int i = 0 ; s[i] ; i ++)
  13. {
  14. if(s[i] == '0')
  15. {
  16. if(! amcifrenenule)
  17. elim[i] = 1, lastzero = i, cnt ++;
  18. }
  19. else
  20. if(s[i] > '0' && s[i] <= '9')
  21. amcifrenenule = 1;
  22. else
  23. elim[i] = 1, cnt ++;
  24. }
  25.  
  26. if(! amcifrenenule && lastzero != -1)
  27. elim[lastzero] = 0, cnt --;
  28.  
  29. if(cnt == 0)
  30. cout << "CORECT";
  31. else
  32. {
  33. if(! amcifrenenule && lastzero == -1)
  34. cout << "NaN";
  35. else
  36. {
  37. for(int i = 0 ; s[i] ; i ++)
  38. if(elim[i] == 0)
  39. cout << s[i];
  40. cout << endl;
  41. for(int i = 0 ; s[i] ; i ++)
  42. if(elim[i] == 1 && s[i] != ' ')
  43. cout << s[i] << " ";
  44. cout << endl;
  45. }
  46. }
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement