Search
 
SCRIPT & CODE EXAMPLE
 

CPP

lists occurrences of characters in the string c++

int d[27]={0};
for (int i = 0; i < str.length(); i++)	  //AABBCC
	d[str[i] - 'A']++;
for (int i = 0; i < str.length(); i++) 
	if (d[str[i] - 'A'] != 0) {
		cout << str[i] << " "<< d[str[i] - 'A'] << " "; //A 2 B 2 C 2 
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ compare type 
Cpp :: c/c++ windows api socket wrappers 
Cpp :: c++98 check if character is integer 
Cpp :: closing a ifstream file c++ 
Cpp :: c++ insert hashmap 
Cpp :: cpp malloc 
Cpp :: statements 
Cpp :: hide window c++ 
Cpp :: unordered_map c++ 
Cpp :: evennumbers 1 to 100 
Cpp :: educative 
Cpp :: C++, binary search recursive 
Cpp :: c++ string concatenation 
Cpp :: copy constructor for vector c++ 
Cpp :: 1. Two Sum 
Cpp :: unique element in array in c 
Cpp :: malloc 2d array cpp 
Cpp :: remove elements from vector 
Cpp :: c++ bit shift wrap 
Cpp :: online converter c++ to c 
Cpp :: c++c 
Cpp :: why the << operator is friend 
Cpp :: how-to-read-until-eof-from-cin-in-c++ 
Cpp :: find n unique integers sum up to zero 
Cpp :: kruskal algorithm 
Cpp :: how to create a custom event in ue4 c++ 
Cpp :: Z-function 
Cpp :: multi variable assignment cpp 
Cpp :: unions c++ 
Cpp :: C++ Converting Celsius to Kelvin 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =