Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int lenstr = 0, i, j, hold, numOfRepetitions = 0;
- char str[100];
- cout << "Write your sentence: ";
- cin.getline(str, 100);
- for(lenstr = 0;str[lenstr] != '\0';lenstr++){
- }
- for(i = 0;i < lenstr;i++){
- if (str[i] >= 'A' && str[i] <= 'z'){
- if (str[i] >= 'A' && str[i] <= 'Z'){
- }
- if (str[i] >= 'a' && str[i] <= 'z'){
- str[i] -= 32;
- }
- }
- }
- for (int j = 1; j < lenstr; j++){
- for (int i = 0; i < lenstr - 1; i++){
- if (str[i] > str[i + 1]){
- hold = str[i];
- str[i] = str[i + 1];
- str[i + 1] = hold;
- }
- }
- }
- for(i = 0;i < lenstr;i++){
- numOfRepetitions = 0;
- if(str[i] >= 'A' && str[i] <= 'Z'){
- numOfRepetitions++;
- if(str[i] == str[i + 1]){
- numOfRepetitions++;
- }
- }
- if(numOfRepetitions != false){
- cout << str[i] << " - " << numOfRepetitions << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement