職業訓練
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
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)
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 {
| ^~~~