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
|
#include <stdlib.h> // Contains system()
#include <cstring>
#include <iostream>
using namespace std;
int main(int argc, char** argv){
cout << "\n\n";
cout << "*******************************************\n";
cout << "** Start of Input Scanner\n";
cout << "*******************************************";
char input[200];
for(int i = 0; i < 200; i++){
input[i] = '\0';
}
printf("\n\nInput some text...");
cin.getline(input, 200);
printf("\nYou input '%s'\n", input);
char consonants[42] = { 'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z',
'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z' };
char vowels[10] = { 'a','e','i','o','u',
'A','E','I','O','U' };
int consonantCount = 0;
int vowelCount = 0;
int unidentifiedCount = 0;
bool identifiedCharacter;
printf("\n\nScan started...\n");
for(int i = 0; i < 200; i++){
if(input[i]=='\0'){
i == 200;
}else{
identifiedCharacter = false;
printf("\n\tScanning for '%c'...", input[i]);
// Check Consonants
for(int j = 0; j < 42; j++){
if(input[i] == consonants[j]){
printf(" match found.");
consonantCount++;
identifiedCharacter = true;
j = 42;
}
}
if(!identifiedCharacter){
// Check vowels
for(int j = 0; j < 10; j++){
if(input[i] == vowels[j]){
printf(" match found.");
vowelCount++;
identifiedCharacter = true;
j = 10;
}
}
}
// Check to see if the character was identified
if(!identifiedCharacter){
unidentifiedCount++;
printf(" no matches found.");
}
}
}
printf("\n\nScan finished.");
printf("\n\nConstanants detected: %u", consonantCount);
printf("\nVowels detected: %u", vowelCount);
printf("\nUnidentified chatacters detected: %u", unidentifiedCount);
cout << "\n\n";
cout << "*******************************************\n";
cout << "** End of Input Scanner\n";
cout << "*******************************************";
cout << "\n\n";
return 0;
}
|