1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include<iostream.h>
#include<iomanip.h>
int main()
{
char Word;
int loop = 0;
char a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
char const Letters = 52;
int const Counter = 52;
char NumLetters[Letters] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int LetterCount[Counter]= {0};
char entireword[15];
int spot = 0;
char fullword[spot];
char Info(int LetterCount[],char NumLetters[], char entireword[], char (*Calculations)());
char userinput(char entireword[]);
char Calculations(char entireword [], int LetterCount [], char NumLetters [],int loop);
cout<<endl;
userinput(entireword);
Calculations(entireword,LetterCount,NumLetters,loop);
Info(LetterCount,NumLetters,entireword,Calculations);
system("pause");
return 0;
}
char Calculations(char entireword [], int LetterCount [], char NumLetters [], int loop)
{
loop = 0;
while (loop < strlen(entireword))
{
for (int Letters =0, Counter = 0, i = 0; Letters < 52; Letters++, Counter++,i++)
{
if(NumLetters[Letters] == entireword[i])
LetterCount[Counter]++;
}
loop++;
}
return 0;
}
char userinput(char entireword[])
{
cout<<setw(26)<<"LETTER COUNTS"<<endl;
cout<<"******************************************"<<endl;
cout<<"Enter the word to be letter counted ";
cin.getline(entireword, 15);
cout << endl;
strlen(entireword);
}
char Info(int LetterCount[],char NumLetters[],char entireword[],char (*Calculations)())
{
int loop = 0;
Calculations(entireword,LetterCount,NumLetters,loop);
for (int Counter = 0,Letters = 0 ; Counter < 52; Counter++, Letters++)
{
if (LetterCount[Counter]>0)
{
cout<<"There are "<<LetterCount[Counter]<<" "<<NumLetters[Letters]<<"'s"<<endl;
}
}
cout<<"There are "<<strlen(entireword)<<" Letters in the word '";
for(int i = 0; i < strlen(entireword); i++)
{
cout << entireword[i];
}
cout<<"'";
cout<<endl;
}
|