Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int getLenght(char *str)
- {
- int i;
- while(str[i])
- {
- i++;
- }
- return i;
- }
- char myUppercase(char str)
- {
- return str >= 'a' && str <= 'z' ? str + 'Z' - 'z' : str;
- }
- void getSymbolsLenght(char *str)
- {
- int num = getLenght(str);
- for(int i = 0;i < num;++i)
- {
- for(int j = i+1;j < num;++j)
- {
- if(str[j] < str[i])
- {
- int temp = str[i];
- str[i] = str[j];
- str[j] = temp;
- }
- }
- }
- for(int i = 0;i < getLenght(str);++i)
- {
- int sum = 1;
- for(int j = i+1;j < getLenght(str);++j)
- {
- if(str[i] == str[j])
- {
- sum++;
- for(int k = j;k < getLenght(str);k++)
- {
- str[k] = str[k+1];
- }
- }
- }
- char c = str[i];
- c = myUppercase(c);
- cout << c << " = " << sum << endl;
- }
- }
- int main()
- {
- char string['A'+'a'-1];
- cout << "String: ";
- cin.getline(string, 'A'+'a'-1);
- getSymbolsLenght(string);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement