#include<bits/stdc++.h> using namespace std; string IntToString(int arr[], int k){ string ans; for(int i = 0;i<k;i++){ ans+= to_string(arr[i]); } return ans; } void StringToInt(string s){ vector<int>v; map<int, int> mp; for(int i = 0;i<s.length();i++){ v.push_back(s[i]-'0'); } sort(v.begin(), v.end()); for(int i = 0;i<v.size();i++){ mp[v[i]]++; } cout<<"counting the frequency : \n"; for(auto i:mp){ cout<<i.first<<" "<<i.second<<endl; } } int main(){ string s = "123343233434435"; int brr[] = {2,3,4,5,6,7}; int n = sizeof(brr)/sizeof(brr[0]); cout<<IntToString(brr, n)<<endl; StringToInt(s); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter