Created
November 1, 2016 15:31
-
-
Save saisumit/ea45a876754f0523373b62954aeb4eb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <bits/stdc++.h> | |
| using namespace std; | |
| #define FOR(i, n) for (int i = 0; i < n; i++) | |
| // IMPLEMENT PARITY CHECK | |
| // odd parity error | |
| int main ( ) | |
| { | |
| string s ; | |
| cout<<"Enter the received string" << endl ; | |
| cin >> s ; | |
| int n = s.length() ; | |
| vector<int> a( n ) ; | |
| FOR( i , n ) if( s[i] == '0' ) a[i] = 0 ; else a[i] = 1 ; | |
| int pa = 0 ; | |
| FOR( i , n ) pa ^= a[i] ; | |
| if( pa ) cout<<" Error in recieved string " << endl ; | |
| else cout<<" No error " << endl ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment