Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define SIZE 30
- #include <bits/stdc++.h>
- using namespace std;
- void printCharWithFreq(string str)
- {
- int n = str.size();
- int freq[SIZE];
- memset(freq, 0, sizeof(freq));
- for (int i = 0; i < n; i++)
- freq[str[i] - 'a']++;
- for (int i = 0; i < n; i++)
- {
- if (freq[str[i] - 'a'] != 0)
- {
- cout << str[i] << freq[str[i] - 'a'] << " ";
- }
- freq[str[i] - 'a'] = 0;
- }
- }
- int main()
- {
- string str = "venividivici";
- printCharWithFreq(str);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement