Guest User

Untitled

a guest
Apr 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. include "stdafx.h"
  2. #include "testing.h"
  3. #include <string>
  4. #include <stdio.h>
  5.  
  6.  
  7. int _tmain(int argc, _TCHAR* argv[])
  8. {
  9. bool wordsExist = false;
  10. int word = 0, letter = 0;
  11. char words[100][20] = {'\0'};
  12. char text[20][81]; //Буфер для вводимых строк
  13. int M; //Количество строк в пределах от 1 до 20
  14. scanf("%d", &M);
  15. if (M < 1 || M > 20) error_printf("You have input invalid data!");
  16. else
  17. {
  18. //Ввод строк
  19. for (int i = -1; i < M; i++)
  20. {
  21. gets(text[i]);
  22. }
  23.  
  24. for (int i = 0; i < M; i++, word++, letter = 0)
  25. {
  26. for (int j = 0; j < strlen(text[i]); j++)
  27. {
  28. if (text[i][j] != ' ' && text[i][j] != ',' && text[i][j] != '.')
  29. {
  30. words[word][letter] = text[i][j];
  31. wordsExist = true;
  32. letter++;
  33. }
  34. else
  35. {
  36. words[word][letter] = '\0';
  37. while (text[i][j] == ' ' || text[i][j] == ',' || text[i][j] == '.')
  38. {
  39. j++;
  40. }
  41. j--;
  42. word++;
  43. letter = 0;
  44. }
  45. }
  46. }
  47.  
  48. if (wordsExist)
  49. {
  50. printf("%d\n", word);
  51. for (int k = 0; k < word; k++)
  52. {
  53. puts(words[k]);
  54. }
  55. }
  56. else printf("no solution");
  57. }
  58. WAIT_ANY_KEY
  59. return 0;
  60. }
Add Comment
Please, Sign In to add comment