64,683
社区成员
发帖
与我相关
我的任务
分享
#include <stdlib.h>
#include <stdio.h>
#define nx 57
#define ny 54
#define start 2004001 //change here
#define finish 2004366 //change here
char Input_name[255], Output_name[255];
unsigned char image[ny][nx];
int out[ny][nx];
FILE *Input, *Output;
int main(void)
{
int x, y;
int count;
count = start;
do {
sprintf(Input_name, "%7d.Lai_1km.dat", count); //2008001.Lai_1km.dat // change here
sprintf(Output_name, "%7d.Lai.txt", count); //2008001.Lai.txt // change here
// for input
if((Input=fopen(Input_name,"rb"))==NULL){
printf("Cannot open input image!\n");
exit(0);
}
for (y=0; y<ny; y++){
for (x=0; x<nx; x++){
image[y][x]=(unsigned char)fgetc(Input);
out[y][x] = image[y][x];
}
}
printf("%d\n",out[0][0]);
// for output
if((Output=fopen(Output_name, "wt")) == NULL) {
printf("Failed to write out !\n");
exit(0);
}
for (y=0; y<ny; y++){
for (x=0; x<nx; x++){
fprintf(Output, "%5d", out[y][x]);
}
fprintf(Output, "\n");
}
fclose(Output);
count = count + 8;
} while (count <= finish);
}