Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void)
- {
- FILE *finput = fopen("matrix.in", "rb");
- FILE *foutput = fopen("trace.out", "wb");
- short int size;
- int byte, number, step = 1;
- fread(&byte, 1, 1, finput);
- size = byte * 256;
- fread(&byte, 1, 1, finput);
- size += byte;
- long long trace = 0;
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- {
- number = 0;
- for (int h = 0; h < 4; h++)
- {
- fread(&byte, 1, 1, finput);
- number *= 256;
- number += byte;
- }
- if (step % (size+1) == 1)
- {
- trace += number;
- }
- step++;
- }
- }
- fwrite(&trace, sizeof(long long int), 1, foutput);
- fclose(finput);
- fclose(foutput);
- FILE *finput1 = fopen("trace.out", "rb");
- int array[8];
- for (int i = 0; i < 8; i++)
- {
- fread(&array[i], 1, 1, finput1);
- }
- fclose(finput1);
- FILE *finput2 = fopen("trace.out", "wb");
- for (int i = 7; i >= 0; i--)
- {
- fwrite(&array[i], 1, 1, finput2);
- }
- fclose(finput2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement