Advertisement
Guest User

paritateoji

a guest
Feb 19th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. using namespace std;
  5. ifstream fin ("paritate.in");
  6. ofstream fout ("paritate.out");
  7.  
  8. char am[60005];
  9. int incorect[60005];
  10.  
  11. int main()
  12. {
  13. char x,par;
  14. int c1,i,k=0,inc=0;
  15. bool corect=true;
  16. while (fin>>par)
  17. {
  18. k++;
  19. int r=0;
  20. c1=0;
  21. for (i=1; i<=7; i++)
  22. {
  23. fin>>x;
  24. if (x=='1')
  25. {
  26. c1++;
  27. }
  28. r=r*2+x-48;
  29. }
  30. am[k]=char(r);
  31. if (par%2!=c1%2)
  32. {
  33. corect=false;
  34. inc++;
  35. incorect[inc]=k-1;
  36. }
  37. }
  38. if (corect==true)
  39. {
  40. fout<<"DA\n";
  41. for (i=1; i<=k; i++)
  42. {
  43. fout<<am[i];
  44. }
  45. }
  46. else
  47. {
  48. fout<<"NU\n";
  49. for (i=1; i<=inc; i++)
  50. {
  51. fout<<incorect[i]<<" ";
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement