473,480 Members | 4,852 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Occurrence of letters in String

7 New Member
hi
Occurrence of letters in String. Get string from KB of any length & print letters coming maximum time first than second largest….. i.e in descending order.
program should be implemented using link list n dymami memory allocation.
Output look like if u enter string aababbbcba
b 5 times
a 4 times
c 1 times just like that


Regards
Nivedita Prasad
Dec 29 '09 #1
1 1664
newb16
687 Contributor
Not sure about "n dymami"(?) and link list part though. Also it prints most frequent in the bottom :(
#include <map>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define vbe(x)x.begin(),x.end()
typedef map<char,int>V;typedef multimap<int,char>S;
struct cx{V&Q;cx(V&v):Q(v){}void operator()(char q){if(Q.find(q)==Q.end())Q[q]=0;Q[q]++;}};
struct rcx{V&Q;S&T;rcx(V&v,S&q):Q(v),T(q){}void operator()(V::value_type x){T.insert(S::value_type(x.second,x.first));}};
struct pcx{S&Q;pcx(S&q):Q(q){}void operator()(S::value_type x){cout<<x.second<<" "<<x.first<<endl;}};
int main(){V v;string s;getline(cin,s);
{cx C(v); for_each(vbe(s),C);}
S q; {rcx C(v,q); for_each(vbe(v),C);}
{pcx C(q);for_each(vbe(q),C);}}
Dec 29 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1815
by: thenetflyer | last post by:
<?php /* Using a function to perform an operation to an occurrence before returning it to the replacement string does not work in preg_replace. Consider the following code in which I want to...
2
2789
by: Edward K. Ream | last post by:
From the documentation for the string module at: C:\Python23\Doc\Python-Docs-2.3.1\lib\module-string.html letters: The concatenation of the strings lowercase and uppercase described below....
19
2158
by: Johannes Nix | last post by:
Hello, yesterday I met a cute person (after my dance class) who told me about an interesting experiment regarding cognition. People were told to read a typed text; However, in every word in the...
2
1770
by: Eric W. Sirko | last post by:
Hi, Eric van der Vlist's book XML Schema says that we can use xs:key to declare co-occurrence constraints. The example he uses (boiled down a bit) is a "book" element that must have either an...
1
4315
by: Robert | last post by:
How can I query an existing table and update a field in each record in the table with the occurrence count of each record e.g. update field to 1 (= first record occurrence), update field to 2 for...
5
3165
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
6
5774
by: Registered User | last post by:
Hi experts, I'm trying to write a program to solve the following exercise: Accept three strings from the user. Find the first occurrence of the first string in the third string. If it is present...
6
3923
by: Xernoth | last post by:
Hi, I have an exercise that requests the following: Write a function that reads words from an input stream and stores them in a vector. Use that function both to write programs that count the...
4
1672
by: nivedita prasad | last post by:
hi Occurrence of letters in String. Get string from KB of any length & print letters coming maximum time first than second largest….. i.e in descending order. program should be implemented...
0
7040
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6736
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6908
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4478
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2994
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.