Snippets Collections
#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;
}
star

Mon Oct 10 2022 17:29:48 GMT+0000 (Coordinated Universal Time)

#frequency #string_to_int_array #int_to_string_array #vector #c++

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension