Guest User

Untitled

a guest
Oct 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. /* *
  2. * Exercise 1-12. Write a program that prints its input one word per line.
  3. * */
  4.  
  5. #include <stdio.h>
  6. #define IS_UPPER(N) ((N) >= 'A' && (N) <= 'Z') /* 'A'==65 && 'Z'==90 */
  7. #define IS_LOWER(N) ((N) >= 'a' && (N) <= 'z') /* 'a'==97 && 'z'==122 */
  8. #define IS_ALPHA(N) (IS_LOWER(N) || IS_UPPER(N)) /* [A-Za-z] x*/
  9. #define OUT 0
  10. #define IN 1
  11. int main(void)
  12. {
  13. int c = EOF, state = OUT;
  14. while ((c = getchar()) != EOF) {
  15. if (IS_ALPHA(c)) {
  16. state = IN;
  17. putchar(c);
  18. }
  19. else if (state == IN) {
  20. state = OUT;
  21. putchar('\n');
  22. }
  23. }
  24.  
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment