fork download
  1. /* package whatever; // don't place package name! */
  2. /*class A
  3. {
  4.   int i,j;
  5.   voidshow()
  6.   System.out.println("i = "+i++ j= "+j");
  7.   }
  8.   class B extends A
  9.   {
  10.   int k;
  11.   void shark()
  12.   {
  13.   System.out.println("k =+k");
  14.   }
  15.   void num()
  16.   {
  17.   System.out.println ("i+J+k="i+J+k);
  18.   }
  19.   }
  20.   class Inherit demo
  21.   {
  22.   svm(string or {}
  23.   {
  24.   A sup = new A ();
  25.   sup.show = ();
  26.   B sub = New B();
  27.   sub.k= 15;
  28.   sub.showk();
  29.   sub.i=100;
  30.   sub.j=50;
  31.   sub.sum = ();
  32.   sub.show ()
  33.   }}
  34.  
  35.  
  36.   }
  37.  
  38.   This source code accompanies the article, "Using The Golay Error Detection And
  39.   Correction Code", by Hank Wallace. This program demonstrates use of the Golay
  40.   code.
  41.   Usage: G DATA Encode/Correct/Verify/Test
  42.   where DATA is the data to be encoded, codeword to be corrected,
  43.   or codeword to be checked for errors. DATA is hexadecimal.
  44.   Examples:
  45.   G 555 E encodes information value 555 and prints a codeword
  46.   G ABC123 C corrects codeword ABC123
  47.   G ABC123 V checks codeword ABC123 for errors
  48.   G ABC123 T tests routines, ABC123 is a dummy parameter
  49.   This program may be freely incorporated into your programs as needed. It
  50.   compiles under Borland's Turbo C 2.0. No warranty of any kind is granted.
  51.   */
  52. #include "stdio.h"
  53. #include "conio.h"
  54. #define POLY 0xAE3 /* or use the other polynomial, 0xC75 */
  55.  
  56. /* ====================================================== */
  57.  
  58. unsigned long golay(unsigned long cw)
  59. /* This function calculates [23,12] Golay codewords.
  60.   The format of the returned longint is
  61.   [checkbits(11),data(12)]. */
  62. {
  63. int i;
  64. unsigned long c;
  65. cw&=0xfffl;
  66. c=cw; /* save original codeword */
  67. for (i=1; i<=12; i++) /* examine each data bit */
  68. {
  69. if (cw & 1) /* test data bit */
  70. cw^=POLY; /* XOR polynomial */
  71. cw>>=1; /* shift intermediate result */
  72. }
  73. return((cw<<12)|c); /* assemble codeword */
  74. }
  75.  
  76. /* ====================================================== */
  77.  
  78. int parity(unsigned long cw)
  79. /* This function checks the overall parity of codeword cw.
  80.   If parity is even, 0 is returned, else 1. */
  81. {
  82. unsigned char p;
  83.  
  84. /* XOR the bytes of the codeword */
  85. p=*(unsigned char*)&cw;
  86. p^=*((unsigned char*)&cw+1);
  87. p^=*((unsigned char*)&cw+2);
  88.  
  89. /* XOR the halves of the intermediate result */
  90. p=p ^ (p>>4);
  91. p=p ^ (p>>2);
  92. p=p ^ (p>>1);
  93.  
  94. /* return the parity result */
  95. return(p & 1);
  96. }
  97.  
  98. /* ====================================================== */
  99.  
  100. unsigned long syndrome(unsigned long cw)
  101. /* This function calculates and returns the syndrome
  102.   of a [23,12] Golay codeword. */
  103. {
  104. int i;
  105. cw&=0x7fffffl;
  106. for (i=1; i<=12; i++) /* examine each data bit */
  107. {
  108. if (cw & 1) /* test data bit */
  109. cw^=POLY; /* XOR polynomial */
  110. cw>>=1; /* shift intermediate result */
  111. }
  112. return(cw<<12); /* value pairs with upper bits of cw */
  113. }
  114.  
  115. /* ====================================================== */
  116.  
  117. int weight(unsigned long cw)
  118. /* This function calculates the weight of
  119.   23 bit codeword cw. */
  120. {
  121. int bits,k;
  122.  
  123. /* nibble weight table */
  124. const char wgt[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
  125.  
  126. bits=0; /* bit counter */
  127. k=0;
  128. /* do all bits, six nibbles max */
  129. while ((k<6) && (cw))
  130. {
  131. bits=bits+wgt[cw & 0xf];
  132. cw>>=4;
  133. k++;
  134. }
  135.  
  136. return(bits);
  137. }
  138.  
  139. /* ====================================================== */
  140.  
  141. unsigned long rotate_left(unsigned long cw, int n)
  142. /* This function rotates 23 bit codeword cw left by n bits. */
  143. {
  144. int i;
  145.  
  146. if (n != 0)
  147. {
  148. for (i=1; i<=n; i++)
  149. {
  150. if ((cw & 0x400000l) != 0)
  151. cw=(cw << 1) | 1;
  152. else
  153. cw<<=1;
  154. }
  155. }
  156.  
  157. return(cw & 0x7fffffl);
  158. }
  159.  
  160. /* ====================================================== */
  161.  
  162. unsigned long rotate_right(unsigned long cw, int n)
  163. /* This function rotates 23 bit codeword cw right by n bits. */
  164. {
  165. int i;
  166.  
  167. if (n != 0)
  168. {
  169. for (i=1; i<=n; i++)
  170. {
  171. if ((cw & 1) != 0)
  172. cw=(cw >> 1) | 0x400000l;
  173. else
  174. cw>>=1;
  175. }
  176. }
  177.  
  178. return(cw & 0x7fffffl);
  179. }
  180.  
  181. /* ====================================================== */
  182.  
  183. unsigned long correct(unsigned long cw, int *errs)
  184. /* This function corrects Golay [23,12] codeword cw, returning the
  185.   corrected codeword. This function will produce the corrected codeword
  186.   for three or fewer errors. It will produce some other valid Golay
  187.   codeword for four or more errors, possibly not the intended
  188.   one. *errs is set to the number of bit errors corrected. */
  189. {
  190. unsigned char
  191. w; /* current syndrome limit weight, 2 or 3 */
  192. unsigned long
  193. mask; /* mask for bit flipping */
  194. int
  195. i,j; /* index */
  196. unsigned long
  197. s, /* calculated syndrome */
  198. cwsaver; /* saves initial value of cw */
  199.  
  200. cwsaver=cw; /* save */
  201. *errs=0;
  202. w=3; /* initial syndrome weight threshold */
  203. j=-1; /* -1 = no trial bit flipping on first pass */
  204. mask=1;
  205. while (j<23) /* flip each trial bit */
  206. {
  207. if (j != -1) /* toggle a trial bit */
  208. {
  209. if (j>0) /* restore last trial bit */
  210. {
  211. cw=cwsaver ^ mask;
  212. mask+=mask; /* point to next bit */
  213. }
  214. cw=cwsaver ^ mask; /* flip next trial bit */
  215. w=2; /* lower the threshold while bit diddling */
  216. }
  217.  
  218. s=syndrome(cw); /* look for errors */
  219. if (s) /* errors exist */
  220. {
  221. for (i=0; i<23; i++) /* check syndrome of each cyclic shift */
  222. {
  223. if ((*errs=weight(s)) <= w) /* syndrome matches error pattern */
  224. {
  225. cw=cw ^ s; /* remove errors */
  226. cw=rotate_right(cw,i); /* unrotate data */
  227. return(s=cw);
  228. }
  229. else
  230. {
  231. cw=rotate_left(cw,1); /* rotate to next pattern */
  232. s=syndrome(cw); /* calc new syndrome */
  233. }
  234. }
  235. j++; /* toggle next trial bit */
  236. }
  237. else
  238. return(cw); /* return corrected codeword */
  239. }
  240.  
  241. return(cwsaver); /* return original if no corrections */
  242. } /* correct */
  243.  
  244. /* ====================================================== */
  245.  
  246. int decode(int correct_mode, int *errs, unsigned long *cw)
  247. /* This function decodes codeword *cw in one of two modes. If correct_mode
  248.   is nonzero, error correction is attempted, with *errs set to the number of
  249.   bits corrected, and returning 0 if no errors exist, or 1 if parity errors
  250.   exist. If correct_mode is zero, error detection is performed on *cw,
  251.   returning 0 if no errors exist, 1 if an overall parity error exists, and
  252.   2 if a codeword error exists. */
  253. {
  254. unsigned long parity_bit;
  255.  
  256. if (correct_mode) /* correct errors */
  257. {
  258. parity_bit=*cw & 0x800000l; /* save parity bit */
  259. *cw&=~0x800000l; /* remove parity bit for correction */
  260.  
  261. *cw=correct(*cw, errs); /* correct up to three bits */
  262. *cw|=parity_bit; /* restore parity bit */
  263.  
  264. /* check for 4 bit errors */
  265. if (parity(*cw)) /* odd parity is an error */
  266. return(1);
  267. return(0); /* no errors */
  268. }
  269. else /* detect errors only */
  270. {
  271. *errs=0;
  272. if (parity(*cw)) /* odd parity is an error */
  273. {
  274. *errs=1;
  275. return(1);
  276. }
  277. if (syndrome(*cw))
  278. {
  279. *errs=1;
  280. return(2);
  281. }
  282. else
  283. return(0); /* no errors */
  284. }
  285. } /* decode */
  286.  
  287. /* ====================================================== */
  288.  
  289. void golay_test(void)
  290. /* This function tests the Golay routines for detection and correction
  291.   of various patterns of error_limit bit errors. The error_mask cycles
  292.   over all possible values, and error_limit selects the maximum number
  293.   of induced errors. */
  294. {
  295. unsigned long
  296. error_mask, /* bitwise mask for inducing errors */
  297. trashed_codeword, /* the codeword for trial correction */
  298. virgin_codeword; /* the original codeword without errors */
  299. unsigned char
  300. pass=1, /* assume test passes */
  301. error_limit=3; /* select number of induced bit errors here */
  302. int
  303. error_count; /* receives number of errors corrected */
  304.  
  305. virgin_codeword=golay(0x555); /* make a test codeword */
  306. if (parity(virgin_codeword))
  307. virgin_codeword^=0x800000l;
  308. for (error_mask=0; error_mask<0x800000l; error_mask++)
  309. {
  310. /* filter the mask for the selected number of bit errors */
  311. if (weight(error_mask) <= error_limit) /* you can make this faster! */
  312. {
  313. trashed_codeword=virgin_codeword ^ error_mask; /* induce bit errors */
  314.  
  315. decode(1,&error_count,&trashed_codeword); /* try to correct bit errors */
  316.  
  317. if (trashed_codeword ^ virgin_codeword)
  318. {
  319. printf("Unable to correct %d errors induced with error mask = 0x%lX\n",
  320. weight(error_mask),error_mask);
  321. pass=0;
  322. }
  323.  
  324. if (kbhit()) /* look for user input */
  325. {
  326. if (getch() == 27) return; /* escape exits */
  327.  
  328. /* other key prints status */
  329. printf("Current test count = %ld of %ld\n",error_mask,0x800000l);
  330. }
  331. }
  332. }
  333. printf("Golay test %s!\n",pass?"PASSED":"FAILED");
  334. }
  335.  
  336. /* ====================================================== */
  337.  
  338. void main(int argument_count, char *argument[])
  339. {
  340. int i,j;
  341. unsigned long l,g;
  342. const char *errmsg = "Usage: G DATA Encode/Correct/Verify/Test\n\n"
  343. " where DATA is the data to be encoded, codeword to be corrected,\n"
  344. " or codeword to be checked for errors. DATA is hexadecimal.\n\n"
  345. "Examples:\n\n"
  346. " G 555 E encodes information value 555 and prints a codeword\n"
  347. " G ABC123 C corrects codeword ABC123\n"
  348. " G ABC123 V checks codeword ABC123 for errors\n"
  349. " G ABC123 T tests routines, ABC123 is a dummy parameter\n\n";
  350.  
  351. if (argument_count != 3)
  352. {
  353. printf(errmsg);
  354. exit(0);
  355. }
  356.  
  357. if (sscanf(argument[1],"%lx",&l) != 1)
  358. {
  359. printf(errmsg);
  360. exit(0);
  361. }
  362.  
  363. switch (toupper(*argument[2]))
  364. {
  365. case 'E': /* encode */
  366. l&=0xfff;
  367. l=golay(l);
  368. if (parity(l)) l^=0x800000l;
  369. printf("Codeword = %lX\n",l);
  370. break;
  371.  
  372. case 'V': /* verify */
  373. if (decode(0,&i,&l))
  374. printf("Codeword %lX is not a Golay codeword.\n",l);
  375. else
  376. printf("Codeword %lX is a Golay codeword.\n",l);
  377. break;
  378.  
  379. case 'C': /* correct */
  380. g=l; /* save initial codeword */
  381. j=decode(1,&i,&l);
  382. if ((j) && (i))
  383. printf("Codeword %lX had %d bits corrected,\n"
  384. "resulting in codeword %lX with a parity error.\n",g,i,l);
  385. else
  386. if ((j == 0) && (i))
  387. printf("Codeword %lX had %d bits corrected, resulting in codeword %lX.\n",g,i,l);
  388. else
  389. if ((j) && (i == 0))
  390. printf("Codeword %lX has a parity error. No bits were corrected.\n",g);
  391. else
  392. if ((j == 0) && (i == 0))
  393. printf("Codeword %lX does not require correction.\n",g);
  394. break;
  395.  
  396. case 'T': /* test */
  397. printf("Press SPACE for status, ESC to exit test...\n");
  398. golay_test();
  399. break;
  400.  
  401. default:
  402. printf(errmsg);
  403. exit(0);
  404. }
  405. }
  406.  
  407. /* end of G.C */
  408.  
  409.  
  410. import java.util.*;
  411. import java.lang.*;
  412. import java.io.*;
  413.  
  414. /* Name of the class has to be "Main" only if the class is public. */
  415. class Ideone
  416. {
  417. public static void main (String[] args) throws java.lang.Exception
  418. {
  419. // your code goes here
  420. }
  421. }
Success #stdin #stdout 0.03s 25532KB
stdin
i+J+k =165
stdout
/* package whatever; // don't place package name! */
/*class A
{
    int i,j;
           voidshow()
        System.out.println("i = "+i++ j= "+j");
    }
      class B extends A 
    {
        int k;
        void shark()
        {
         System.out.println("k =+k");
            }
            void num()
            {
                System.out.println ("i+J+k="i+J+k);
            }
    }
    class Inherit demo
    {
        svm(string or {}
        {
            A sup = new A ();
            sup.show = ();
            B sub = New B();
            sub.k= 15;
            sub.showk();
            sub.i=100;
            sub.j=50;
            sub.sum = ();
            sub.show ()
        }}
        
            
        }
    
    This source code accompanies the article, "Using The Golay Error Detection And
    Correction Code", by Hank Wallace. This program demonstrates use of the Golay
    code.
      Usage: G DATA Encode/Correct/Verify/Test
        where DATA is the data to be encoded, codeword to be corrected,
        or codeword to be checked for errors. DATA is hexadecimal.
      Examples:
        G 555 E      encodes information value 555 and prints a codeword
        G ABC123 C   corrects codeword ABC123
        G ABC123 V   checks codeword ABC123 for errors
        G ABC123 T   tests routines, ABC123 is a dummy parameter
    This program may be freely incorporated into your programs as needed. It
    compiles under Borland's Turbo C 2.0. No warranty of any kind is granted.
    */
    #include "stdio.h"
    #include "conio.h"
    #define POLY  0xAE3  /* or use the other polynomial, 0xC75 */
    
    /* ====================================================== */
    
    unsigned long golay(unsigned long cw)
    /* This function calculates [23,12] Golay codewords.
      The format of the returned longint is
      [checkbits(11),data(12)]. */
    {
      int i;
      unsigned long c;
      cw&=0xfffl;
      c=cw; /* save original codeword */
      for (i=1; i<=12; i++)  /* examine each data bit */
        {
          if (cw & 1)        /* test data bit */
            cw^=POLY;        /* XOR polynomial */
          cw>>=1;            /* shift intermediate result */
        }
      return((cw<<12)|c);    /* assemble codeword */
    }
    
    /* ====================================================== */
    
    int parity(unsigned long cw)
    /* This function checks the overall parity of codeword cw.
      If parity is even, 0 is returned, else 1. */
    {
      unsigned char p;
    
      /* XOR the bytes of the codeword */
      p=*(unsigned char*)&cw;
      p^=*((unsigned char*)&cw+1);
      p^=*((unsigned char*)&cw+2);
    
      /* XOR the halves of the intermediate result */
      p=p ^ (p>>4);
      p=p ^ (p>>2);
      p=p ^ (p>>1);
    
      /* return the parity result */
      return(p & 1);
    }
    
    /* ====================================================== */
    
    unsigned long syndrome(unsigned long cw)
    /* This function calculates and returns the syndrome
      of a [23,12] Golay codeword. */
    {
      int i;
      cw&=0x7fffffl;
      for (i=1; i<=12; i++)  /* examine each data bit */
        {
          if (cw & 1)        /* test data bit */
            cw^=POLY;        /* XOR polynomial */
          cw>>=1;            /* shift intermediate result */
        }
      return(cw<<12);        /* value pairs with upper bits of cw */
    }
    
    /* ====================================================== */
    
    int weight(unsigned long cw)
    /* This function calculates the weight of
      23 bit codeword cw. */
    {
      int bits,k;
    
      /* nibble weight table */
      const char wgt[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
    
      bits=0; /* bit counter */
      k=0;
      /* do all bits, six nibbles max */
      while ((k<6) && (cw))
        {
          bits=bits+wgt[cw & 0xf];
          cw>>=4;
          k++;
        }
    
      return(bits);
    }
    
    /* ====================================================== */
    
    unsigned long rotate_left(unsigned long cw, int n)
    /* This function rotates 23 bit codeword cw left by n bits. */
    {
      int i;
    
      if (n != 0)
        {
          for (i=1; i<=n; i++)
            {
              if ((cw & 0x400000l) != 0)
                cw=(cw << 1) | 1;
              else
                cw<<=1;
            }
        }
    
      return(cw & 0x7fffffl);
    }
    
    /* ====================================================== */
    
    unsigned long rotate_right(unsigned long cw, int n)
    /* This function rotates 23 bit codeword cw right by n bits. */
    {
      int i;
    
      if (n != 0)
        {
          for (i=1; i<=n; i++)
            {
              if ((cw & 1) != 0)
                cw=(cw >> 1) | 0x400000l;
              else
                cw>>=1;
            }
        }
    
      return(cw & 0x7fffffl);
    }
    
    /* ====================================================== */
    
    unsigned long correct(unsigned long cw, int *errs)
    /* This function corrects Golay [23,12] codeword cw, returning the
      corrected codeword. This function will produce the corrected codeword
      for three or fewer errors. It will produce some other valid Golay
      codeword for four or more errors, possibly not the intended
      one. *errs is set to the number of bit errors corrected. */
    {
      unsigned char
        w;                /* current syndrome limit weight, 2 or 3 */
      unsigned long
        mask;             /* mask for bit flipping */
      int
        i,j;              /* index */
      unsigned long
        s,                /* calculated syndrome */
        cwsaver;          /* saves initial value of cw */
    
      cwsaver=cw;         /* save */
      *errs=0;
      w=3;                /* initial syndrome weight threshold */
      j=-1;               /* -1 = no trial bit flipping on first pass */
      mask=1;
      while (j<23) /* flip each trial bit */
        {
          if (j != -1) /* toggle a trial bit */
            {
              if (j>0) /* restore last trial bit */
                {
                  cw=cwsaver ^ mask;
                  mask+=mask; /* point to next bit */
                }
              cw=cwsaver ^ mask; /* flip next trial bit */
              w=2; /* lower the threshold while bit diddling */
            }
    
          s=syndrome(cw); /* look for errors */
          if (s) /* errors exist */
            {
              for (i=0; i<23; i++) /* check syndrome of each cyclic shift */
                {
                  if ((*errs=weight(s)) <= w) /* syndrome matches error pattern */
                    {
                      cw=cw ^ s;              /* remove errors */
                      cw=rotate_right(cw,i);  /* unrotate data */
                      return(s=cw);
                    }
                  else
                    {
                      cw=rotate_left(cw,1);   /* rotate to next pattern */
                      s=syndrome(cw);         /* calc new syndrome */
                    }
                }
              j++; /* toggle next trial bit */
            }
          else
            return(cw); /* return corrected codeword */
        }
    
      return(cwsaver); /* return original if no corrections */
    } /* correct */
    
    /* ====================================================== */
    
    int decode(int correct_mode, int *errs, unsigned long *cw)
    /* This function decodes codeword *cw in one of two modes. If correct_mode
      is nonzero, error correction is attempted, with *errs set to the number of
      bits corrected, and returning 0 if no errors exist, or 1 if parity errors
      exist. If correct_mode is zero, error detection is performed on *cw,
      returning 0 if no errors exist, 1 if an overall parity error exists, and
      2 if a codeword error exists. */
    {
      unsigned long parity_bit;
    
      if (correct_mode)               /* correct errors */
        {
          parity_bit=*cw & 0x800000l; /* save parity bit */
          *cw&=~0x800000l;            /* remove parity bit for correction */
    
          *cw=correct(*cw, errs);     /* correct up to three bits */
          *cw|=parity_bit;            /* restore parity bit */
    
          /* check for 4 bit errors */
          if (parity(*cw))            /* odd parity is an error */
            return(1);
          return(0); /* no errors */
        }
      else /* detect errors only */
        {
          *errs=0;
          if (parity(*cw)) /* odd parity is an error */
            {
              *errs=1;
              return(1);
            }
          if (syndrome(*cw))
            {
              *errs=1;
              return(2);
            }
          else
            return(0); /* no errors */
        }
    } /* decode */
    
    /* ====================================================== */
    
    void golay_test(void)
    /* This function tests the Golay routines for detection and correction
      of various patterns of error_limit bit errors. The error_mask cycles
      over all possible values, and error_limit selects the maximum number
      of induced errors. */
    {
      unsigned long
        error_mask,         /* bitwise mask for inducing errors */
        trashed_codeword,   /* the codeword for trial correction */
        virgin_codeword;    /* the original codeword without errors */
      unsigned char
        pass=1,             /* assume test passes */
        error_limit=3;      /* select number of induced bit errors here */
      int
        error_count;        /* receives number of errors corrected */
    
      virgin_codeword=golay(0x555); /* make a test codeword */
      if (parity(virgin_codeword))
        virgin_codeword^=0x800000l;
      for (error_mask=0; error_mask<0x800000l; error_mask++)
        {
          /* filter the mask for the selected number of bit errors */
          if (weight(error_mask) <= error_limit) /* you can make this faster! */
            {
              trashed_codeword=virgin_codeword ^ error_mask; /* induce bit errors */
    
              decode(1,&error_count,&trashed_codeword); /* try to correct bit errors */
    
              if (trashed_codeword ^ virgin_codeword)
                {
                  printf("Unable to correct %d errors induced with error mask = 0x%lX\n",
                    weight(error_mask),error_mask);
                  pass=0;
                }
    
              if (kbhit()) /* look for user input */
                {
                  if (getch() == 27) return; /* escape exits */
    
                  /* other key prints status */
                  printf("Current test count = %ld of %ld\n",error_mask,0x800000l);
                }
            }
        }
      printf("Golay test %s!\n",pass?"PASSED":"FAILED");
    }
    
    /* ====================================================== */
    
    void main(int argument_count, char *argument[])
    {
      int i,j;
      unsigned long l,g;
      const char *errmsg = "Usage: G DATA Encode/Correct/Verify/Test\n\n"
                 "  where DATA is the data to be encoded, codeword to be corrected,\n"
                 "  or codeword to be checked for errors. DATA is hexadecimal.\n\n"
                 "Examples:\n\n"
                 "  G 555 E      encodes information value 555 and prints a codeword\n"
                 "  G ABC123 C   corrects codeword ABC123\n"
                 "  G ABC123 V   checks codeword ABC123 for errors\n"
                 "  G ABC123 T   tests routines, ABC123 is a dummy parameter\n\n";
    
      if (argument_count != 3)
        {
          printf(errmsg);
          exit(0);
        }
    
      if (sscanf(argument[1],"%lx",&l) != 1)
        {
          printf(errmsg);
          exit(0);
        }
    
      switch (toupper(*argument[2]))
        {
          case 'E': /* encode */
            l&=0xfff;
            l=golay(l);
            if (parity(l)) l^=0x800000l;
            printf("Codeword = %lX\n",l);
            break;
    
          case 'V': /* verify */
            if (decode(0,&i,&l))
              printf("Codeword %lX is not a Golay codeword.\n",l);
            else
              printf("Codeword %lX is a Golay codeword.\n",l);
            break;
    
          case 'C': /* correct */
            g=l; /* save initial codeword */
            j=decode(1,&i,&l);
            if ((j) && (i))
              printf("Codeword %lX had %d bits corrected,\n"
                     "resulting in codeword %lX with a parity error.\n",g,i,l);
            else
              if ((j == 0) && (i))
                printf("Codeword %lX had %d bits corrected, resulting in codeword %lX.\n",g,i,l);
              else
                if ((j) && (i == 0))
                  printf("Codeword %lX has a parity error. No bits were corrected.\n",g);
                else
                  if ((j == 0) && (i == 0))
                    printf("Codeword %lX does not require correction.\n",g);
            break;
    
          case 'T': /* test */
            printf("Press SPACE for status, ESC to exit test...\n");
            golay_test();
            break;
    
          default:
            printf(errmsg);
            exit(0);
        }
    }
    
    /* end of G.C */


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
	}
}