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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/*****************************************************************************************************
******************************************************************************************************/
//declare Header Files
#include <iostream>
#include <string>
using namespace std;
//declare funtions
void LetterArray (char letterlist[], char ch);
int numb_count[26] = {0};
string word;
//start main function
int main ()
{
//declare variables
char ch =' ';
char letterList[] = {'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'};
cout << "\nPlease enter a word: ";
cin >> word;
cout<<"The word contains "<<word.length()<<" characters."<<endl;
while (ch != '0')
{
cout << "What letter would like to guess? (Enter zero to quit). ";
cin >> ch;
LetterArray (letterList, ch);
for (int i =0; i < 26; i++)
{
if (ch==letterList[i])
cout <<"\nThere are "<<numb_count[i]<<" "<<ch<<"'s"<<endl;
}
}
cout<<"You found these letters \n"<<endl;
for ( int i=0; i<26; i++)
{
if (numb_count[i] > 0)
cout<< letterList[i]<<" ";
}
cout << "\nThanks you"<<endl;
system ("PAUSE");
return 0;
//end main
}
void LetterArray ( char letterList[], char ch)
{
int counter;
for (int count = 0; count < word.length(); count++)
{
if (ch == word[count])
{
for (counter =0; counter< 26; counter++)
{
if (ch == letterList[counter])
numb_count[counter]++;
}
}
}
}
void count (int numb_count[])
{
}
| |