psyche08
03-10-2005, 02:52 AM
here's my sample problem..
write a program to read text of line and output the list of all letters occur in text,together the number of times each letter occur the line.the letter should be listed in the order of most frequently occuring letter and next and so forth..use two parallel array,one is hold the letter and the other hold the number of lines that corresponding d letter.
ex.. do be do d=2
o=2
b=1
heres my program:\
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int main()
{
int bletter=0, eletter=0, aletter=0, uletter=0,tletter=0,iletter=0fletter=0, wletter=0,lletter=0,wdletter=0,notmatch=0;
char a;
clrscr();
cout<<"enter sentence:";
cin>>a;
if(wdletter % 12 ==0)
cout<<endl;
for(a=0;a<buf.size();a++)
{
switch(buf[a])
{
case'b':
++aletter;
break;
case'e':
++eletter;
break;
case'a':
++aletter;
break;
case'u':
++uletter;
break;
case't':
++tletter;
break;
case'i':
++iletter;
break;
case'f':
++fletter;
break;
case'w':
++wletter;
break;
case'l':
++lletter;
break;
default:
++notmatch;
break;
}
}
cout<<"\n\n";
<<"b:"<<bletter<<endl;
<<"e:"<<eletter<<endl;
<<"a:"<<aletter<<endl;
<<"u:"<<uletter<<endl;
<<"t:"<<tletter<<endl;
<<:i:"<<iletter<<endl;
<<"f:"<<fletter<<endl;
<<"u:"<<wletter<<endl
<<"l:"<<lletter<<endl;
getch();
return 0;
}
is my program right?if not,can u help me whats the reason why and what the code should be/
thank you very much
write a program to read text of line and output the list of all letters occur in text,together the number of times each letter occur the line.the letter should be listed in the order of most frequently occuring letter and next and so forth..use two parallel array,one is hold the letter and the other hold the number of lines that corresponding d letter.
ex.. do be do d=2
o=2
b=1
heres my program:\
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
int main()
{
int bletter=0, eletter=0, aletter=0, uletter=0,tletter=0,iletter=0fletter=0, wletter=0,lletter=0,wdletter=0,notmatch=0;
char a;
clrscr();
cout<<"enter sentence:";
cin>>a;
if(wdletter % 12 ==0)
cout<<endl;
for(a=0;a<buf.size();a++)
{
switch(buf[a])
{
case'b':
++aletter;
break;
case'e':
++eletter;
break;
case'a':
++aletter;
break;
case'u':
++uletter;
break;
case't':
++tletter;
break;
case'i':
++iletter;
break;
case'f':
++fletter;
break;
case'w':
++wletter;
break;
case'l':
++lletter;
break;
default:
++notmatch;
break;
}
}
cout<<"\n\n";
<<"b:"<<bletter<<endl;
<<"e:"<<eletter<<endl;
<<"a:"<<aletter<<endl;
<<"u:"<<uletter<<endl;
<<"t:"<<tletter<<endl;
<<:i:"<<iletter<<endl;
<<"f:"<<fletter<<endl;
<<"u:"<<wletter<<endl
<<"l:"<<lletter<<endl;
getch();
return 0;
}
is my program right?if not,can u help me whats the reason why and what the code should be/
thank you very much