programming stype 2 , The C Puzzle Book

職業訓練
https://qiita.com/kaizen_nagoya/items/95368b63fa21d64271ec

Programmer, Day 6
https://qiita.com/kaizen_nagoya/items/632d8f191268e88eb86a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識, error(21), coding(28)
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

The C Puzzle Book
https://efrei.poupa.net/Programmation%20en%20C/Cours/The_C_Puzzle_Book.pdf

defs.h "The C Puzzle Book"
https://qiita.com/kaizen_nagoya/items/6d284651ac1244963bd9

```c:ps2.c
        done=i=0;
        while( i<MAXI && !done ) {
                if( (x/=2)>1 ) { i++; continue; }
                done++;
        }
        // (Programming Style 2.1)

        {
                if(A) { B; return; }
                if(C) { D; return; }
                if(E) { F; return; }
                G; return;
        }
        // (Programming Style 2.2)

        plusflg=zeroflg=negflg=0;
        if( a>0 ) ++plusflg;
        if( a==0 ) ++zeroflg;
        else if( !plusflg ) ++negflg;
        // (Programming Style 2.3)

        i=0;
        while((c=getchar())!=EOF){
                if(c!='\n'&&c!='\t'){s[i++]=c;continue;}
                if(c=='\n')break;
                if(c=='\t')c=' ';
                s[i++]=c;
        }
        // (Programming Style 2.4)

        if( x!=0 ) {
                if( j>k ) y=j/x;
                else y=k/x;
        }
        else {
                if( j>k ) y=j/NEARZERO;
                else y=k/NEARZERO;
        }
        // (Programming Style 2.5)

```
```shell-session:bash
$ gcc ps2.c
ps2.c:1:9: warning: data definition has no type or storage class
    1 |         done=i=0;
      |         ^~~~
ps2.c:1:9: warning: type defaults to ‘int’ in declaration of ‘done’ [-Wimplicit-int]
ps2.c:1:14: error: ‘i’ undeclared here (not in a function)
    1 |         done=i=0;
      |              ^
ps2.c:2:9: error: expected identifier or ‘(’ before ‘while’
    2 |         while( i<MAXI && !done ) {
      |         ^~~~~
ps2.c:8:9: error: expected identifier or ‘(’ before ‘{’ token
    8 |         {
      |         ^
ps2.c:16:9: warning: data definition has no type or storage class
   16 |         plusflg=zeroflg=negflg=0;
      |         ^~~~~~~
ps2.c:16:9: warning: type defaults to ‘int’ in declaration of ‘plusflg’ [-Wimplicit-int]
ps2.c:16:17: error: ‘zeroflg’ undeclared here (not in a function)
   16 |         plusflg=zeroflg=negflg=0;
      |                 ^~~~~~~
ps2.c:16:25: error: ‘negflg’ undeclared here (not in a function)
   16 |         plusflg=zeroflg=negflg=0;
      |                         ^~~~~~
ps2.c:17:9: error: expected identifier or ‘(’ before ‘if’
   17 |         if( a>0 ) ++plusflg;
      |         ^~
ps2.c:18:9: error: expected identifier or ‘(’ before ‘if’
   18 |         if( a==0 ) ++zeroflg;
      |         ^~
ps2.c:19:9: error: expected identifier or ‘(’ before ‘else’
   19 |         else if( !plusflg ) ++negflg;
      |         ^~~~
ps2.c:22:9: warning: data definition has no type or storage class
   22 |         i=0;
      |         ^
ps2.c:22:9: warning: type defaults to ‘int’ in declaration of ‘i’ [-Wimplicit-int]
ps2.c:23:9: error: expected identifier or ‘(’ before ‘while’
   23 |         while((c=getchar())!=EOF){
      |         ^~~~~
ps2.c:31:9: error: expected identifier or ‘(’ before ‘if’
   31 |         if( x!=0 ) {
      |         ^~
ps2.c:35:9: error: expected identifier or ‘(’ before ‘else’
   35 |         else {
      |         ^~~~
```


```c:ps2a.c
#include "defs.h"

#define A 1
#define B PR(d,2)
#define C 3
#define D PR(d,4)
#define E 5
#define F PR(d,6)
#define G PR(d,7)
#define MAXI 8
#define NEARZERO 9

int main(void){
        int i, y, k, x, = 0, a;
        int done=i=0;
        char c='0';
        char * s[E];
        while( i<MAXI && !done ) {
                if( (x/=2)>1 ) { i++; continue; }
                done++;
        }
        // (Programming Style 2.1)

        {
                if(A) { B; return; }
                if(C) { D; return; }
                if(E) { F; return; }
                G; return;
        }
        // (Programming Style 2.2)
        int zeroflg, negflg;
        int plusflg=zeroflg=negflg=0;
        if( a>0 ) ++plusflg;
        if( a==0 ) ++zeroflg;
        else if( !plusflg ) ++negflg;
        // (Programming Style 2.3)

        i=0;
        while((c=getchar())!=EOF){
                if(c!='\n'&&c!='\t'){s[i++]=c;continue;}
                if(c=='\n')break;
                if(c=='\t')c=' ';
                s[i++]=c;
        }
        // (Programming Style 2.4)

        if( x!=0 ) {
                if( j>k ) y=j/x;
                else y=k/x;
        }
        else {
                if( j>k ) y=j/NEARZERO;
                else y=k/NEARZERO;
        }
        // (Programming Style 2.5)
        return EXIT_SUCCESS;
}
```


```shell-session:bash
$ gcc ps2a.c
ps2a.c: In function ‘main’:
ps2a.c:14:25: error: expected identifier or ‘(’ before ‘=’ token
   14 |         int i, y, k, x, = 0, a;
      |                         ^
ps2a.c:25:28: warning: ‘return’ with no value, in function returning non-void
   25 |                 if(A) { B; return; }
      |                            ^~~~~~
ps2a.c:13:5: note: declared here
   13 | int main(void){
      |     ^~~~
ps2a.c:26:28: warning: ‘return’ with no value, in function returning non-void
   26 |                 if(C) { D; return; }
      |                            ^~~~~~
ps2a.c:13:5: note: declared here
   13 | int main(void){
      |     ^~~~
ps2a.c:27:28: warning: ‘return’ with no value, in function returning non-void
   27 |                 if(E) { F; return; }
      |                            ^~~~~~
ps2a.c:13:5: note: declared here
   13 | int main(void){
      |     ^~~~
ps2a.c:28:20: warning: ‘return’ with no value, in function returning non-void
   28 |                 G; return;
      |                    ^~~~~~
ps2a.c:13:5: note: declared here
   13 | int main(void){
      |     ^~~~
ps2a.c:33:13: error: ‘a’ undeclared (first use in this function)
   33 |         if( a>0 ) ++plusflg;
      |             ^
ps2a.c:33:13: note: each undeclared identifier is reported only once for each function it appears in
ps2a.c:40:44: warning: assignment to ‘char *’ from ‘char’ makes pointer from integer without a cast [-Wint-conversion]
   40 |                 if(c!='\n'&&c!='\t'){s[i++]=c;continue;}
      |                                            ^
ps2a.c:43:23: warning: assignment to ‘char *’ from ‘char’ makes pointer from integer without a cast [-Wint-conversion]
   43 |                 s[i++]=c;
      |                       ^
ps2a.c:48:21: error: ‘j’ undeclared (first use in this function)
   48 |                 if( j>k ) y=j/x;
          |   ^
```
ca