dot_testing/progs/scream.c

35 lines
610 B
C
Raw Normal View History

2020-12-31 18:24:47 -06:00
#include <stdio.h>
#include <ctype.h>
/* written on new year's eve 2020
* good night and good riddance */
char newchar(char c, int i) {
2021-02-16 10:38:21 -06:00
switch(i) {
case 0:
if(isupper(c)) return c + 32;
if(c == 33) return -2;
else return c;
case 1:
if(islower(c)) return c - 32;
if(c == 33) return -2;
else return c;
default: return -1;
}
2020-12-31 18:24:47 -06:00
}
int advi(int i) {
2021-02-16 10:38:21 -06:00
switch(i) {
case 0: return 1;
case 1: return 0;
default: return -1;
}
2020-12-31 18:24:47 -06:00
}
int main(void) {
2021-02-16 10:38:21 -06:00
char c;
int i = 0;
while((c = getchar()) != EOF) {
putchar(newchar(c, i));
i = advi(i);
}
2020-12-31 18:24:47 -06:00
}