Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
32
Task/Odd-word-problem/C/odd-word-problem.c
Normal file
32
Task/Odd-word-problem/C/odd-word-problem.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int do_char(int odd, void (*f)(void))
|
||||
{
|
||||
int c = getchar();
|
||||
|
||||
void write_out(void) {
|
||||
putchar(c);
|
||||
if (f) f();
|
||||
}
|
||||
|
||||
if (!odd) putchar(c);
|
||||
|
||||
if (isalpha(c))
|
||||
return do_char(odd, write_out);
|
||||
|
||||
if (odd) {
|
||||
if (f) f();
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
return c != '.';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i = 1;
|
||||
while (do_char(i = !i, 0));
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue