Advertisement
Guest User

Specially gor Gul'shanat XD

a guest
Oct 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. 906
  2.  
  3. #include <iostream>
  4. #include <cstring>
  5. using namespace std;
  6. void count(char *word)
  7. {
  8. int count = 0;
  9. int tempcount = 0;
  10. int term = 0;
  11. int sterm = 0;
  12. int eterm = 0;
  13. bool flag1 = true;
  14. bool flag2 = true;
  15. for (int i = 0;i < strlen(word);i++)
  16. {
  17. if (word[i] == '0' || word[i] == '1' || word[i] == '2' || word[i] == '3' || word[i] == '4' || word[i] == '5' || word[i] == '6' || word[i] == '7' || word[i] == '8' || word[i] == '9')
  18. {
  19. count++;
  20. if (flag1 == true)
  21. {
  22. term = i;
  23. flag1 = false;
  24. }
  25. flag2 = true;
  26. }
  27. else
  28. {
  29. count = 0;
  30. if (flag2 == true)
  31. {
  32. flag2 = false;
  33. }
  34. flag1 = true;
  35. }
  36. if (count > tempcount)
  37. {
  38. tempcount = count;
  39. sterm = term;
  40. eterm = i;
  41. }
  42. }
  43. char ptr[1000] = { '\0' };
  44. for (int i = sterm, j = 0;i <= eterm;i++, j++)
  45. {
  46. ptr[j] = word[i];
  47. }
  48. int len = strlen(ptr);
  49. int ost = len % 3;
  50. for (int i = 0; i<ost; i++)
  51. cout << ptr[i];
  52. for (int i = ost; i<len; i += 3)
  53. {
  54. if (ost != 0)
  55. cout << " " << ptr[i] << ptr[i + 1] << ptr[i + 2];
  56. else
  57. cout << ptr[i] << ptr[i + 1] << ptr[i + 2] << " ";
  58. }
  59. cout << endl;
  60. }
  61. int main()
  62. {
  63. char word[1001] = { '\0' };
  64. cin.getline(word, 1000);
  65. count(word);
  66. return 0;
  67. }
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. 912
  86.  
  87. #include <iostream>
  88. #include <cstring>
  89. #include <iomanip>
  90. #include <cctype>
  91. #define DELIMS " ,.!?-0123456789\n"
  92.  
  93. using namespace std;
  94.  
  95. void avg(char *str)
  96. {
  97. double sum = 0;
  98. double count = 0;
  99.  
  100. char *token = strtok(str, DELIMS);
  101. while (token != 0)
  102. {
  103. ++count;
  104. sum += strlen(token);
  105. token = strtok(0, DELIMS);
  106. }
  107. if (count == 0)
  108. {
  109. cout << "0.0";
  110. }
  111. else
  112. {
  113. cout << fixed << setprecision(9) << sum / count << endl;
  114. }
  115. }
  116. bool isreal(char x[]);
  117. int main()
  118. {
  119. char text[50];
  120. cin.getline(text, 50, '#');
  121. bool isreal = false;
  122. for (int i = 0; i<strlen(text); i++)
  123. {
  124. if(!(isalnum(text[i]) || text[i] == '?' || text[i] == ',' || text[i] == '.' || text[i] == '!' || text[i] == '-' || text[i] == ' '))
  125. {
  126. isreal = true;
  127. }
  128. }
  129. if (isreal == false)
  130. {
  131. avg(text);
  132. }
  133. return 0;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement