Advertisement
crzhel

Untitled

Apr 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int lenstr = 0, i, j, hold, numOfRepetitions = 0;
  8. char str[100];
  9. cout << "Write your sentence: ";
  10.  
  11. cin.getline(str, 100);
  12.  
  13. for(lenstr = 0;str[lenstr] != '\0';lenstr++){
  14.  
  15. }
  16.  
  17. for(i = 0;i < lenstr;i++){
  18. if (str[i] >= 'A' && str[i] <= 'z'){
  19. if (str[i] >= 'A' && str[i] <= 'Z'){
  20. }
  21. if (str[i] >= 'a' && str[i] <= 'z'){
  22. str[i] -= 32;
  23. }
  24. }
  25. }
  26.  
  27. for (int j = 1; j < lenstr; j++){
  28. for (int i = 0; i < lenstr - 1; i++){
  29. if (str[i] > str[i + 1]){
  30. hold = str[i];
  31. str[i] = str[i + 1];
  32. str[i + 1] = hold;
  33. }
  34. }
  35. }
  36. for(i = 0;i < lenstr;i++){
  37. numOfRepetitions = 0;
  38. if(str[i] >= 'A' && str[i] <= 'Z'){
  39. numOfRepetitions++;
  40. if(str[i] == str[i + 1]){
  41. numOfRepetitions++;
  42. }
  43. }
  44. if(numOfRepetitions != false){
  45. cout << str[i] << " - " << numOfRepetitions << endl;
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement