Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- char str[] = "A computer is a device that processes data according to a set of instructions known as a program";
- char delimiters[] = " ;.,!\t\n";
- cout << str << endl;
- char* curWord = strtok(str, delimiters);
- char* maxStr = 0;
- int maxNum = 0;
- int i = 0;
- char consonants[] = "cmptrsdvhngfkwm";
- while (curWord != NULL)
- {
- int curNum = 0;
- for (i = 0; curWord[i] != 0; ++i)
- {
- if (strchr(consonants, curWord[i])) ++curNum;
- }
- if (maxNum < curNum)
- {
- maxNum = curNum;
- maxStr = curWord;
- }
- printf("\n%s", curWord);
- cout << ": " << curNum;
- curWord = strtok(NULL, delimiters);
- }
- cout << endl;
- cout << "The most consonant letters has a word: " << maxStr << ":\t " << maxNum << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement