fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. char txt[1000]="";
  7. int wyrazy, liczby;
  8.  
  9. while(fgets(txt, sizeof(txt), stdin)){
  10. wyrazy=0, liczby=0;
  11. for(int i=0; i<strlen(txt); i++){
  12. if(txt[i]>='a' && txt[i]<='z' || txt[i]>='A' && txt[i]<='Z'){
  13. while(txt[i]!=' ') i++;
  14. wyrazy++;
  15. }
  16. if(txt[i]>='0' && txt[i]<='9'){
  17. while(txt[i]!=' ') i++;
  18. liczby++;
  19. }
  20. }
  21. printf("%d %d\n", liczby, wyrazy);
  22. }
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 4528KB
stdin
                   Romek            ma 2 koty i 3                    psy
2 plus 2            jest           rowne 4
stdout
2 5
3 3