我有一个系数为 256 的文件,我想反转该文件的每个 64 系数并将结果保存在另一个文件中。我尝试编写我的想法,但结果是错误的。
int main()
{
/***********************************inversion coefficients*****************/
FILE* org = NULL; // original file
FILE* inv = NULL; // file content inverse coefficient
float det; // readed coefficient
float tabinv[256]; // intermediate table witch will content iverse coefficient
org = fopen("det.txt", "r");
inv = fopen("inverse.txt", "w");
int j = 64;
int p = j;
int copt = 0;
while (copt < 256)
{
for (int i = j - 64; i < j; i++)
{
fscanf(org, "%f", &det);
tabinv[p - 1 - i] = det;
copt++;
}
p = p + 64;
j = p;
}
for (int k = 0; k < 256; k++){
fprintf(inv, "%f\n", tabinv[k]);
}
fclose(org);
fclose(inv);
return 0;
}