fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // int a =10;
  6. // int b=6;
  7. // int result=a^b; // xor operation(exclusive or)
  8. // cout<<result;
  9. vector<int> arr={1,3,4,8};
  10. int n=arr.size();
  11. vector<int> xorr(n+1,0);
  12. for(int i=1;i<=n;i++){
  13. int result=arr[i-1] ^ xorr[i-1];
  14. xorr[i]=result;
  15. }
  16.  
  17. for(int i=1;i<=n;i++){
  18.  
  19. cout<<xorr[i]<<" ";
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
1      2      6      14