Florii11

3

Jan 4th, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     FILE* fp=fopen("numere.txt","r");
  7.     FILE* f=fopen("numere_out.txt","w");
  8.     if(!fp)
  9.         return -1;
  10.     int n, key;
  11.     fscanf(fp,"%d",&n);
  12.     fscanf(fp,"%d",&key);
  13.     for(int i=0;i<n;i++)
  14.     {
  15.         int x;
  16.         fscanf(fp,"%d",&x);
  17.         fprintf(f,"%d ",x^key);
  18.     }
  19.     fclose(fp);
  20.     fclose(f);
  21.     fp=fopen("numere_out.txt","r");
  22.     FILE* g=fopen("numere_out2.txt","w");
  23.     for(int i=0;i<n;i++)
  24.     {
  25.         int x;
  26.         fscanf(fp,"%d",&x);
  27.         fprintf(f,"%d ",x^key);
  28.     }
  29.     fclose(fp);
  30.     fclose(g);
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment