View Code of Problem 36

#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>

using namespace std;


int main()
{
	int T;
	cin >> T;

	for (int i = 0; i < T; i++) {

		string str;
		cin >> str;

		int count[26] = { 0 };
		for (int i = 0; i < str.size(); i++) {

			count[str[i] - 'A']++;
		}

		for (int i = 0; i < 26; i++) {

			if (count[i]) {

				cout << count[i] << (char)(i + 'A');
			}
		}

		cout << endl;
	}
}

Double click to view unformatted code.


Back to problem 36