Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <locale.h>
  3. #include <string.h>
  4.  
  5. int main(void) {
  6. setlocale(LC_ALL, "en_US.utf8");
  7.  
  8. char strOne[100], strTwo[100];
  9. char space = ' ';
  10. char *ach;
  11. int spaces = 0;
  12.  
  13. printf("Введите первую строку: ");
  14. scanf(" %[^\t\n]s",strOne);
  15. printf("Введите вторую строку: ");
  16. scanf(" %[^\t\n]s",strTwo);
  17.  
  18. while(NULL != strchr(strOne, space)) {
  19. ach = strchr(strOne, space);
  20. spaces++;
  21.  
  22. ach = strchr(ach, ach[1]);
  23. strncpy(strOne, ach, 100);
  24. }
  25.  
  26. while(NULL != strchr(strTwo, space)) {
  27. ach = strchr(strTwo, space);
  28. spaces++;
  29.  
  30. ach = strchr(ach, ach[1]);
  31. strncpy(strTwo, ach, 100);
  32. }
  33.  
  34. printf("%d ", spaces + 2);
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement