Advertisement
Guest User

Untitled

a guest
Sep 4th, 2022
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. main()
  5. {
  6. int IN, OUT,c, i,state,l,w[0];
  7. IN=1;
  8. OUT=0;
  9. state = IN;
  10. i=1;
  11. w[i-'0']=0;
  12. printf("w[i] before while %d\n", w[i-'0']);
  13. while ((c = getchar()) != EOF) {printf("w[%d] before 1st if=%d state=%d\n",i, w[i],state);
  14. if (c == ' ' || c == '\n' || c == '\t'){printf("w[%d]after 1st if %d\n",i, w[i-'0']);
  15. state = OUT;}
  16. else if (state==IN){++w[i];printf("w[%d] after ++w[%d]=%d\n",i,i, w[i]);}
  17. else if (state == OUT) {
  18. state = IN;
  19. ++i;
  20. w[i-'0']=0;
  21. }}
  22.  
  23.  
  24.  
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement