a53

VerifNumar

a53
Oct 16th, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. char s[101], ch, numar[101];
  4. int ls, lnr, nrc, sp, nr0=-1, nr01=-1, ok=1;
  5.  
  6. int main()
  7. {
  8. while(cin>>ch)
  9. {
  10. nrc++;
  11. if(isdigit(ch))
  12. {
  13. if(ch=='0')
  14. {
  15. if(lnr)
  16. numar[lnr++]=ch;
  17. else
  18. {
  19. if(nr0<0)
  20. nr0=ls;
  21. else
  22. nr01=ls;
  23. s[ls++]=ch;
  24. }
  25. }
  26. else
  27. numar[lnr++]=ch;
  28. }
  29. else if(ch!=' ')
  30. {
  31. s[ls++]=ch;
  32. ok=0;
  33. }
  34. else sp++;
  35. }
  36. if(lnr)
  37. numar[lnr]='\0';
  38. if(ls)
  39. s[ls]='\0';
  40. if(ok)
  41. {
  42. cout<<"CORECT";
  43. return 0;
  44. }
  45. if(!lnr && nr0<0)
  46. {
  47. cout<<"NaN";
  48. return 0;
  49. }
  50. if(!lnr && nr0>=0)
  51. {
  52. if(nr01<0)
  53. {
  54. cout<<"0\n";
  55. for(int i=0; i<ls; i++)
  56. if(i!=nr0)
  57. cout<<s[i]<<" ";
  58. }
  59. else
  60. {
  61. cout<<"0\n";
  62. for(int i=0; i<ls; i++)
  63. if(i!=nr01)
  64. cout<<s[i]<<" ";
  65. }
  66. return 0;
  67. }
  68. cout<<numar<<'\n';
  69. for(int i=0; i<ls; i++)
  70. cout<<s[i]<<" ";
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment