Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. main() {
  4. FILE *input, *output;
  5. int x, y, numberArray[5][3];
  6.  
  7. input = fopen("input", "r");
  8.  
  9. for (x = 0; x < 5; x++)
  10. for(y = 0; y < 3; y++)
  11. fscanf(input, "%1d", &numberArray[x][y]);
  12.  
  13. fclose(input);
  14.  
  15. for (x = 0; x < 5; x++)
  16. for(y = 0; y < 3; y++){
  17. if(y == 1)
  18. numberArray[x][y] *= 2;
  19. if(y == 2)
  20. numberArray[x][y] *= 4;
  21. }
  22.  
  23. output = fopen("output", "w");
  24.  
  25. for (x = 0; x < 5; x++){
  26. for(y = 0; y < 3; y++)
  27. fprintf(output, "%d ", numberArray[x][y]);
  28. fprintf(output, "\n");
  29. }
  30.  
  31. fclose(output);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement