Advertisement
crzhel

Untitled

Apr 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int lenstr = 0, i, j, x, hold, numOfRepetitions = 0, p = 0;
  8. int massiv[100];
  9. char str[100];
  10. cout << "Write your sentence: ";
  11.  
  12. cin.getline(str, 100);
  13.  
  14. for(lenstr = 0;str[lenstr] != '\0';lenstr++){
  15.  
  16. }
  17.  
  18. for(i = 0;i < lenstr;i++){
  19. if (str[i] >= 'A' && str[i] <= 'z'){
  20. if (str[i] >= 'A' && str[i] <= 'Z'){
  21. }
  22. if (str[i] >= 'a' && str[i] <= 'z'){
  23. str[i] -= 32;
  24. }
  25. }
  26. }
  27.  
  28. for (int j = 1; j < lenstr; j++){
  29. for (int i = 0; i < lenstr - 1; i++){
  30. if (str[i] > str[i + 1]){
  31. hold = str[i];
  32. str[i] = str[i + 1];
  33. str[i + 1] = hold;
  34. }
  35. }
  36. }
  37.  
  38. for(i = 0;i < lenstr;i++){
  39. numOfRepetitions = 0;
  40. j = i;
  41. if(str[i] >= 'A' && str[i] <= 'Z'){
  42. numOfRepetitions++;
  43. while(str[j] == str[j + 1]){
  44. numOfRepetitions++;
  45. j++;
  46. }
  47. }
  48.  
  49. massiv[i] = numOfRepetitions;
  50.  
  51. while(str[i] == str[i + 1]){
  52. i++;
  53. }
  54.  
  55. }
  56.  
  57. for (int j = 1; j < lenstr; j++){
  58. for (int i = 0; i < lenstr + 1; i++){
  59. if (massiv[i] > massiv[i - 1]){
  60. hold = massiv[i];
  61. massiv[i] = massiv[i - 1];
  62. massiv[i - 1] = hold;
  63.  
  64. hold = str[i];
  65. str[i] = str[i - 1];
  66. str[i - 1] = hold;
  67. }
  68. }
  69. }
  70.  
  71. for(i = 0;i < lenstr;i++){
  72. for( ;massiv[i] > 100 || str[i] == str[i + 1] || str[i] == false;i++){
  73. }
  74.  
  75. if(massiv[i] != false){
  76. cout << str[i] << " - " << massiv[i] << endl;
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement