program style 1, 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:ps1.c

#include "defs.h"

void main(void){
        while(A){
                if(B) continue;
                C;
        }
        do if(!A) continue;
        else B;
        C;
        }while (A);
        if(A)
                if(B)
                        if(C) D;
                        else;
                else;
        else
                if(B)
                        if(C) E;
                        else F;
                        else;

        while(( c = getchar()) != '\n';{
                        if( ' ' == c) continue;
                        if( '\t'==c) continue;
                        if( c<'0') return(OTHER);
                        if (c<='9' ) return(DIGIT);
                        if ( <'a') return(OTHER);
                        if (c <='z') return(ALPHA);
                        return(OTHER);
        }
}
```
```
ps1.c: In function ‘main’:
ps1.c:4:15: error: ‘A’ undeclared (first use in this function)
    4 |         while(A){
      |               ^
ps1.c:4:15: note: each undeclared identifier is reported only once for each function it appears in
ps1.c:5:20: error: ‘B’ undeclared (first use in this function)
    5 |                 if(B) continue;
      |                    ^
ps1.c:6:17: error: ‘C’ undeclared (first use in this function)
    6 |                 C;
      |                 ^
ps1.c:10:9: error: expected ‘while’ before ‘C’
   10 |         C;
      |         ^
ps1.c: At top level:
ps1.c:11:10: error: expected identifier or ‘(’ before ‘while’
   11 |         }while (A);
      |          ^~~~~
ps1.c:12:9: error: expected identifier or ‘(’ before ‘if’
   12 |         if(A)
      |         ^~
ps1.c:15:25: error: expected identifier or ‘(’ before ‘else’
   15 |                         else;
      |                         ^~~~
ps1.c:16:17: error: expected identifier or ‘(’ before ‘else’
   16 |                 else;
      |                 ^~~~
ps1.c:17:9: error: expected identifier or ‘(’ before ‘else’
   17 |         else
      |         ^~~~
ps1.c:20:25: error: expected identifier or ‘(’ before ‘else’
   20 |                         else F;
      |                         ^~~~
ps1.c:21:25: error: expected identifier or ‘(’ before ‘else’
   21 |                         else;
      |                         ^~~~
ps1.c:23:9: error: expected identifier or ‘(’ before ‘while’
   23 |         while(( c = getchar()) != '\n';{
      |         ^~~~~
ps1.c:23:40: error: expected identifier or ‘(’ before ‘{’ token
   23 |         while(( c = getchar()) != '\n';{
      |                                        ^
ps1.c:32:1: error: expected identifier or ‘(’ before ‘}’ token
   32 | }
      | ^
```

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

#define A 1
#define B 2
#define C 3
#define D PR(d,4)
#define E PR(d,5)
#define F PR(d,6)
#define OTHER 7
#define DIGIT 8
#define ALPHA a

void main(void){

        while(A){
                if(B) continue;
                C;
        }

        do{ if(!A) continue;
                else B;
                C;
        } while (A);

        if(A)
                if(B)
                        if(C) D;
                        else;
                else;
        else
                if(B)
                        if(C) E;
                        else F;
                else;

        while(( c = getchar()) != '\n';{
                        if( ' ' == c) continue;
                        if( '\t'==c) continue;
                        if( c<'0') return(OTHER);
                        if (c<='9' ) return(DIGIT);
                        if (c <'a') return(OTHER);
                        if (c <='z') return(ALPHA);
                        return(OTHER);
        }
}
```

```shell-session:bash
$ gcc ps1.c
ps1.c: In function ‘main’:
ps1.c:36:17: error: ‘c’ undeclared (first use in this function)
   36 |         while(( c = getchar()) != '\n';{
      |                 ^
ps1.c:36:17: note: each undeclared identifier is reported only once for each function it appears in
ps1.c:36:39: error: expected ‘)’ before ‘;’ token
   36 |         while(( c = getchar()) != '\n';{
      |              ~                        ^
      |                                       )
ps1.c:45:1: error: expected expression before ‘}’ token
   45 | }
      | ^
```

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

void main(void){
        while(A){
                if(B) continue;
                C;
        }
        do if(!A) continue;
        else B;
        C;
        }while (A);
        if(A)
                if(B)
                        if(C) D;
                        else;
                else;
        else
                if(B)
                        if(C) E;
                        else F;
                        else;

        while(( c = getchar()) != '\n';{
                        if( ' ' == c) continue;
                        if( '\t'==c) continue;
                        if( c<'0') return(OTHER);
                        if (c<='9' ) return(DIGIT);
                        if ( <'a') return(OTHER);
                        if (c <='z') return(ALPHA);
                        return(OTHER);
        }
        return XIT_SUCCESS;
        }

```
```shell-session:bash
$ gcc ps1a.c
$ ./a.out
b
z
)
2
3
T
^T
^N
```