/* CSC 310, SPRING 2004, ASSIGNMENT 4. */ #include #include #define N 35 /* Number of bits in a codeword */ #define M 20 /* Number of parity checks */ main (int argc, char **argv) { FILE *Hfile; /* File to read parity check matrix from */ int H[M][N]; /* Parity check matrix */ int change; /* Has scan of parity checks changed anything? */ int r[N]; /* Received vector */ int ne; /* Number of erasures remaining */ int i, j, s, b; /* Check the program arguments. Exit with amessage if they're not valid. */ if (argc!=2) { fprintf(stderr,"Usage: a4-sol parity-check-file\n"); exit(1); } /* Read the parity check matrix. Exit if there's an error reading it. */ Hfile = fopen(argv[1],"r"); for (i = 0; i0) { printf(" Not fully decoded"); } /* Check that it's a codeword if all erasures were removed. */ if (ne==0) { /* Verify that the decoded vector is a codeword, by verifying that all parity checks are satisfied. */ for (i = 0; i