CS计算机代考程序代写 #include

#include
#include

#define WIDTH 8
#define NUM_PIXELS 64

int main() {
FILE *fp;
int num_images = 1;

unsigned char label = 2;

unsigned char pixels[WIDTH][WIDTH] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 255, 255, 255, 255, 255, 0},
{0, 0, 0, 0, 0, 0, 255, 0},
{0, 0, 255, 255, 255, 255, 255, 0},
{0, 0, 255, 0, 0, 0, 0, 0},
{0, 0, 255, 255, 255, 255, 255, 0},
{0, 0, 0, 0, 0, 0, 0, 0}};

if((fp = fopen(“number2”, “wb”)) == NULL) {
perror(“fopen”);
exit(1);
}

fwrite(&num_images, sizeof(int), 1, fp);
fwrite(&label, sizeof(char), 1, fp);
fwrite(pixels,sizeof(unsigned char), NUM_PIXELS, fp);

fclose(fp);
return 0;
}