Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,008 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,341 people online right now. Registration is fast and FREE... Join Now!




Searching Strings for the most repetitve letter in C++

 
Reply to this topicStart new topic

Searching Strings for the most repetitve letter in C++

caelum12
17 Mar, 2008 - 12:52 PM
Post #1

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 1

I need to find a way to search a code for the most repetitive letter and count how many times that letter occurs. Ex. the string (AGSDGHJKLGGJSFG) - G occurs the most, so: G = 5.


User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Searching Strings For The Most Repetitve Letter In C++
17 Mar, 2008 - 12:57 PM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,518



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Can you post the code you've got already?

We're not here to do your homework for you.
User is online!Profile CardPM
+Quote Post

skaoth
RE: Searching Strings For The Most Repetitve Letter In C++
17 Mar, 2008 - 02:02 PM
Post #3

D.I.C Regular
Group Icon

Joined: 7 Nov, 2007
Posts: 342



Thanked: 10 times
Dream Kudos: 100
My Contributions
What you can do is just store the characters of the string into a hash and increment the value by 1 every time you run across the same key.

You can look into the STL map to do this, but you can also just use a simple array to mimic this
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 01:02PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month