Connecting Tech Pros Worldwide Help | Site Map

SYNTAX AND SEMANTICS

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 27th, 2006, 12:05 PM
Prof.Stanley
Guest
 
Posts: n/a
Default SYNTAX AND SEMANTICS

HELLO ALL I AM TRYING TO PUT UP A PROGRAM THAT DETECTS DOUBLE VOWELS
AFTER RECIEVING AN INPUT STRING; MY MAIN PROBLEM LIES IN THE INPUT CAN
SOMEBODY KINDLY HELP DETECT ANY SYNTAX OR SEMANTIC ERRORS:

HERE IS THE CODE:



#include <iostream>
#include <string>
#include <cctype>
using namespace std;

void scanner(char s[]);
bool isVowel(char);
int length(char s[]);

int main(){

//string sentence;
const int max=4096;
char sentence[max];
cout << "Enter $ to terminate!" <<endl;
do{
cout << "\nEnter the input string: ";
getline(sentence,max);
scanner(sentence);
}while(sentence != "$");
return 0;
}

void scanner(char s[]){
int stringSize = length(char s[]);
char current,next;
int count = 0;
int aa,ae,ai,ao,au,ea,ee,ei,eo,eu,ia,ie,ii,io,iu,oa,oe ,oi,oo,ou,
ua,ue,ui,uo,uu;
aa = ae = ai = ao = au = 0;
ea = ee = ei = eo = eu = 0;
ia = ie = ii = io = iu = 0;
oa = oe = oi = oo = ou = 0;
ua = ue = ui = uo = uu = 0;
while(count < stringSize){
current = s[count];
if( (count + 1) == stringSize)
break;
next = s[count + 1];
if(isVowel(current) && isVowel(next)){
//a
current = tolower(current);
next = tolower(next);
if( current == 'a' && next == 'a')
aa++;
else if( current == 'a' && next == 'e')
ae++;
else if( current == 'a' && next == 'i')
ai++;
else if( current == 'a' && next == 'o')
ao++;
else if( current == 'a' && next == 'u')
au++;
//e
else if( current == 'e' && next == 'a')
ea++;
else if( current == 'e' && next == 'e')
ee++;
else if( current == 'e' && next == 'i')
ei++;
else if( current == 'e' && next == 'o')
eo++;
else if( current == 'e' && next == 'u')
eu++;
//i
else if( current == 'i' && next == 'a')
ia++;
else if( current == 'i' && next == 'e')
ie++;
else if( current == 'i' && next == 'i')
ii++;
else if( current == 'i' && next == 'o')
io++;
else if( current == 'i' && next == 'u')
iu++;
//o
else if( current == 'o' && next == 'a')
oa++;
else if( current == 'o' && next == 'e')
oe++;
else if( current == 'o' && next == 'i')
oi++;
else if( current == 'o' && next == 'o')
oo++;
else if( current == 'o' && next == 'u')
ou++;
//u
else if( current == 'u' && next == 'a')
ua++;
else if( current == 'u' && next == 'e')
ue++;
else if( current == 'u' && next == 'i')
ui++;
else if( current == 'u' && next == 'o')
uo++;
else /*( current == 'u' && next == 'u')*/
uu++;

count++;
}
else{
count++;
continue;
}
}
int totalVowels = aa + ae + ai + ao + au +
ea + ee + ei + eo + eu +
ia + ie + ii + io + iu +
oa + oe + oi + oo + ou +
ua + ue + ui + uo + uu ;
if(totalVowels == 0){
cout << "No double vowels!" <<endl;
}
if(aa > 0){
cout << aa <<"x "<<"aa";
totalVowels -= aa;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ae > 0){
cout << ae <<"x "<<"ae";
totalVowels -= ae;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ai > 0){
cout << ai <<"x "<<"ai";
totalVowels -= ai;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ao > 0){
cout << ao <<"x "<<"ao";
totalVowels -= ao;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(au > 0){
cout << au <<"x "<<"au";
totalVowels -= au;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ea > 0){
cout << ea <<"x "<<"ea";
totalVowels -= ea;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ee > 0){
cout << ee <<"x "<<"ee";
totalVowels -= ee;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ei > 0){
cout << ei <<"x "<<"ei";
totalVowels -= ei;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(eo > 0){
cout << eo <<"x "<<"eo";
totalVowels -= eo;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(eu > 0){
cout << eu <<"x "<<"eu";
totalVowels -= eu;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ia > 0){
cout << ia <<"x "<<"ia";
totalVowels -= ia;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ie > 0){
cout << ie <<"x "<<"ie";
totalVowels -= ie;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ii > 0){
cout << ii <<"x "<<"ii";
totalVowels -= ii;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(io > 0){
cout << io <<"x "<<"io";
totalVowels -= io;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(iu > 0){
cout << iu <<"x "<<"iu";
totalVowels -= iu;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(oa > 0){
cout << oa <<"x "<<"oa";
totalVowels -= oa;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(oe > 0){
cout << oe <<"x "<<"oe";
totalVowels -= oe;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(oi > 0){
cout << oi <<"x "<<"oi";
totalVowels -= oi;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(oo > 0){
cout << oo <<"x "<<"oo";
totalVowels -= oo;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ou > 0){
cout << ou <<"x "<<"ou";
totalVowels -= ou;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ua > 0){
cout << ua <<"x "<<"ua";
totalVowels -= ua;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ue > 0){
cout << ue <<"x "<<"ue";
totalVowels -= ue;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(ui > 0){
cout << ui <<"x "<<"ui";
totalVowels -= ui;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(uo > 0){
cout << uo <<"x "<<"uo";
totalVowels -= uo;
if(totalVowels == 0)
cout <<".";
else cout <<", ";
}
if(uu > 0){
cout << uu <<"x "<<"uu"<<".";
totalVowels -=uu;
}
}

bool isVowel(char c){
return (c == 'a' || c == 'A' || c == 'e' ||
c == 'E' || c == 'i' || c == 'I' || c == 'o' ||
c == 'O' || c == 'u' || c == 'U') ;
}

int length(char s[]){

int i=0;
while(s[i]='\0')
i=i+1;

return i;



}


  #2  
Old May 27th, 2006, 12:55 PM
Kai-Uwe Bux
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

Prof.Stanley wrote:
[color=blue]
> HELLO ALL I AM TRYING TO PUT UP A PROGRAM THAT DETECTS DOUBLE VOWELS
> AFTER RECIEVING AN INPUT STRING; MY MAIN PROBLEM LIES IN THE INPUT CAN
> SOMEBODY KINDLY HELP DETECT ANY SYNTAX OR SEMANTIC ERRORS:[/color]

a) Your keyboard has a problem with CAPS-LOCK. You should fix that.

b) For best diagnostics, try Comeau online.

Suggestions and criticism that a human can provide follow below.
[color=blue]
> HERE IS THE CODE:
>
>
>
> #include <iostream>
> #include <string>
> #include <cctype>
> using namespace std;
>
> void scanner(char s[]);
> bool isVowel(char);
> int length(char s[]);[/color]

Note:

a) if the string is 0-terminated, then you should use std::strlen().
b) if the string is not 0-terminated, you are out of luck.
c) you should use strings anyway.
[color=blue]
>
> int main(){
>
> //string sentence;
> const int max=4096;
> char sentence[max];[/color]

Would you use strings, there would be no such arbitrary limitation.
[color=blue]
> cout << "Enter $ to terminate!" <<endl;
> do{
> cout << "\nEnter the input string: ";
> getline(sentence,max);[/color]

std::cin.getline( sentence, max );
[color=blue]
> scanner(sentence);
> }while(sentence != "$");
> return 0;
> }[/color]

Since you used getline and max, the program will not crash nor produce
undefined behavior. It will just not count correctly if there are lines
longer than 4096 characters.

It will also not count correctly, if someone prepares a file that contains 0
characters in some lines.
[color=blue]
>
> void scanner(char s[]){
> int stringSize = length(char s[]);
> char current,next;
> int count = 0;
> int aa,ae,ai,ao,au,ea,ee,ei,eo,eu,ia,ie,ii,io,iu,oa,oe ,oi,oo,ou,
> ua,ue,ui,uo,uu;
> aa = ae = ai = ao = au = 0;
> ea = ee = ei = eo = eu = 0;
> ia = ie = ii = io = iu = 0;
> oa = oe = oi = oo = ou = 0;
> ua = ue = ui = uo = uu = 0;
> while(count < stringSize){
> current = s[count];
> if( (count + 1) == stringSize)
> break;
> next = s[count + 1];
> if(isVowel(current) && isVowel(next)){
> //a
> current = tolower(current);
> next = tolower(next);
> if( current == 'a' && next == 'a')
> aa++;
> else if( current == 'a' && next == 'e')
> ae++;
> else if( current == 'a' && next == 'i')
> ai++;
> else if( current == 'a' && next == 'o')
> ao++;
> else if( current == 'a' && next == 'u')
> au++;
> //e
> else if( current == 'e' && next == 'a')
> ea++;
> else if( current == 'e' && next == 'e')
> ee++;
> else if( current == 'e' && next == 'i')
> ei++;
> else if( current == 'e' && next == 'o')
> eo++;
> else if( current == 'e' && next == 'u')
> eu++;
> //i
> else if( current == 'i' && next == 'a')
> ia++;
> else if( current == 'i' && next == 'e')
> ie++;
> else if( current == 'i' && next == 'i')
> ii++;
> else if( current == 'i' && next == 'o')
> io++;
> else if( current == 'i' && next == 'u')
> iu++;
> //o
> else if( current == 'o' && next == 'a')
> oa++;
> else if( current == 'o' && next == 'e')
> oe++;
> else if( current == 'o' && next == 'i')
> oi++;
> else if( current == 'o' && next == 'o')
> oo++;
> else if( current == 'o' && next == 'u')
> ou++;
> //u
> else if( current == 'u' && next == 'a')
> ua++;
> else if( current == 'u' && next == 'e')
> ue++;
> else if( current == 'u' && next == 'i')
> ui++;
> else if( current == 'u' && next == 'o')
> uo++;
> else /*( current == 'u' && next == 'u')*/
> uu++;
>
> count++;
> }
> else{
> count++;
> continue;
> }
> }
> int totalVowels = aa + ae + ai + ao + au +
> ea + ee + ei + eo + eu +
> ia + ie + ii + io + iu +
> oa + oe + oi + oo + ou +
> ua + ue + ui + uo + uu ;
> if(totalVowels == 0){
> cout << "No double vowels!" <<endl;
> }
> if(aa > 0){
> cout << aa <<"x "<<"aa";
> totalVowels -= aa;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ae > 0){
> cout << ae <<"x "<<"ae";
> totalVowels -= ae;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ai > 0){
> cout << ai <<"x "<<"ai";
> totalVowels -= ai;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ao > 0){
> cout << ao <<"x "<<"ao";
> totalVowels -= ao;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(au > 0){
> cout << au <<"x "<<"au";
> totalVowels -= au;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ea > 0){
> cout << ea <<"x "<<"ea";
> totalVowels -= ea;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ee > 0){
> cout << ee <<"x "<<"ee";
> totalVowels -= ee;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ei > 0){
> cout << ei <<"x "<<"ei";
> totalVowels -= ei;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(eo > 0){
> cout << eo <<"x "<<"eo";
> totalVowels -= eo;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(eu > 0){
> cout << eu <<"x "<<"eu";
> totalVowels -= eu;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ia > 0){
> cout << ia <<"x "<<"ia";
> totalVowels -= ia;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ie > 0){
> cout << ie <<"x "<<"ie";
> totalVowels -= ie;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ii > 0){
> cout << ii <<"x "<<"ii";
> totalVowels -= ii;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(io > 0){
> cout << io <<"x "<<"io";
> totalVowels -= io;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(iu > 0){
> cout << iu <<"x "<<"iu";
> totalVowels -= iu;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(oa > 0){
> cout << oa <<"x "<<"oa";
> totalVowels -= oa;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(oe > 0){
> cout << oe <<"x "<<"oe";
> totalVowels -= oe;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(oi > 0){
> cout << oi <<"x "<<"oi";
> totalVowels -= oi;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(oo > 0){
> cout << oo <<"x "<<"oo";
> totalVowels -= oo;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ou > 0){
> cout << ou <<"x "<<"ou";
> totalVowels -= ou;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ua > 0){
> cout << ua <<"x "<<"ua";
> totalVowels -= ua;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ue > 0){
> cout << ue <<"x "<<"ue";
> totalVowels -= ue;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(ui > 0){
> cout << ui <<"x "<<"ui";
> totalVowels -= ui;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(uo > 0){
> cout << uo <<"x "<<"uo";
> totalVowels -= uo;
> if(totalVowels == 0)
> cout <<".";
> else cout <<", ";
> }
> if(uu > 0){
> cout << uu <<"x "<<"uu"<<".";
> totalVowels -=uu;
> }
> }[/color]

This function mixes analysis and output. Not good. Moreover, it is a
maintainance nightmare. You should consider using something like this:

typedef std::pair< char, char > CharacterPair;
std::map< CharacterPair, unsigned long > PairCount;

void record_vowel_pair( char first, char second, PairCount & count ) {
if ( isVowel(first) && isVowel(second) ) {
++ count[ CharacterPair(first,second) ];
}
}

Maybe some call of tolower() is in order somewhere; that depends on what you
want.
[color=blue]
> bool isVowel(char c){
> return (c == 'a' || c == 'A' || c == 'e' ||
> c == 'E' || c == 'i' || c == 'I' || c == 'o' ||
> c == 'O' || c == 'u' || c == 'U') ;
> }
>
> int length(char s[]){
>
> int i=0;
> while(s[i]='\0')
> i=i+1;
>
> return i;
>
>
>
> }[/color]



Finally, you should reconsider the design: what about something that works
on iterators:

template < typename CharInputIterator >
PairCount record_vowel_pairs ( CharInputIterator from,
CharInputIterator to );

With that signature, main could be like so:

int main ( void ) {
PairCount count =
record_vowel_pairs( std::istream_iterator< char >( std::cin ),
std::istream_iterator< char >() );
print_some_statistics( count );
}

Or, if you insist on doing stuff line by line:

int main ( void ) {
std::string line;
while ( std::cin >> line ) {
PairCount count = record_vowel_pairs( line.begin(), line.end() ) );
print_some_statistics( count );
}
}


Warning: none of my code has been checked by a compiler. It will contain
typos.



Best

Kai-Uwe Bux
  #3  
Old May 27th, 2006, 02:25 PM
benben
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

Prof.Stanley wrote:[color=blue]
> HELLO ALL I AM TRYING TO PUT UP A PROGRAM THAT DETECTS DOUBLE VOWELS
> AFTER RECIEVING AN INPUT STRING; MY MAIN PROBLEM LIES IN THE INPUT CAN
> SOMEBODY KINDLY HELP DETECT ANY SYNTAX OR SEMANTIC ERRORS:
>
> HERE IS THE CODE:
>
>
>
> #include <iostream>
> #include <string>
> #include <cctype>
> using namespace std;
>
> void scanner(char s[]);[/color]

void scanner(const char s[]);
[color=blue]
> bool isVowel(char);
> int length(char s[]);[/color]

int length(const char s[]);

Const correctness matters.
[color=blue]
>
> int main(){
>
> //string sentence;
> const int max=4096;
> char sentence[max];
> cout << "Enter $ to terminate!" <<endl;
> do{
> cout << "\nEnter the input string: ";
> getline(sentence,max);
> scanner(sentence);
> }while(sentence != "$");[/color]

First off, you can't compare two raw strings with the != operator. You
should use std::strcmp:

strcmp(sentence, "$")

or, since you are only interested in the first character:

sentence[0] != '$'

Secondly, you should always check the stream state in a loop. Usually
I'd go with:

while (cin)
{
cout << "blah";
getline(sentence, max);

if (sentence[0] != '$')
scanner(sentence);
}

At least you get the idea.
[color=blue]
> return 0;
> }
>
> void scanner(char s[]){[/color]

[260 lines of code snipped]
[color=blue]
> }[/color]

Wow! That function is way longer than it really should be. But before
giving any tips and hints I'm going to hit you with a number of compiler
error and logical errors.

One way to simplify design is to use the standard library facilities.
For example, a simple scanner can be trivially written as:

void scanner(const char s[])
{
vector<char> vstack;
map<string, unsigned int> m;
unsigned int l = strlen(s);

for (unsigned int i = 0; i <= l; ++i)
{
char c = s[i];

if (isVowel(c))
{
vstack.push_back(tolower(c, locale()));
}
else
{
if (buff.size() == 2)
{
vstack.push_back(0);
++m[&vstack[0]];
}

vstack.clear();
}
}

// print out the content of m, left for exercise
}


[color=blue]
>
> bool isVowel(char c){
> return (c == 'a' || c == 'A' || c == 'e' ||
> c == 'E' || c == 'i' || c == 'I' || c == 'o' ||
> c == 'O' || c == 'u' || c == 'U') ;
> }[/color]

This function isn't lengthy but it is made very inflexible. Consider:

static char vowels[] = "aeiouAEIOU";

for (unsigned int i = 0; i < 10; ++i)
if (c == vowels[i]) return true;

return fail;

[color=blue]
>
> int length(char s[]){
>
> int i=0;
> while(s[i]='\0')
> i=i+1;
>
> return i;
>
>
>
> }
>[/color]

That's just strlen...why do you reinvent the wheel?
  #4  
Old May 27th, 2006, 05:05 PM
osmium
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

"Prof.Stanley" writes:

<snip>[color=blue]
> if( current == 'a' && next == 'a')
> aa++;
> else if( current == 'a' && next == 'e')
> ae++;
> else if( current == 'a' && next == 'i')
> ai++;
> else if( current == 'a' && next == 'o')
> ao++;
> else if( current == 'a' && next == 'u')
> au++;
> //e
> else if( current == 'e' && next == 'a')
> ea++;
> else if( current == 'e' && next == 'e')
> ee++;
> else if( current == 'e' && next == 'i')
> ei++;
> else if( current == 'e' && next == 'o')
> eo++;
> else if( current == 'e' && next == 'u')
> eu++;
> //i
> else if( current == 'i' && next == 'a')
> ia++;
> else if( current == 'i' && next == 'e')
> ie++;
> else if( current == 'i' && next == 'i')
> ii++;
> else if( current == 'i' && next == 'o')
> io++;
> else if( current == 'i' && next == 'u')
> iu++;
> //o
> else if( current == 'o' && next == 'a')
> oa++;
> else if( current == 'o' && next == 'e')
> oe++;
> else if( current == 'o' && next == 'i')
> oi++;
> else if( current == 'o' && next == 'o')
> oo++;
> else if( current == 'o' && next == 'u')
> ou++;
> //u
> else if( current == 'u' && next == 'a')
> ua++;
> else if( current == 'u' && next == 'e')
> ue++;
> else if( current == 'u' && next == 'i')
> ui++;
> else if( current == 'u' && next == 'o')
> uo++;
> else /*( current == 'u' && next == 'u')*/
> uu++;[/color]
<snip>

Kind of on the wordy end of the spectrum. Take a look at this and see if
you can extract some ideas you can use.

----------------------------
#include <iostream>
#include <cctype> // tolower()
using namespace std;

const int a=1, e=2, i=3, o=4, u=5;

// return 0 if not a vowel
int classify(char c)
{
c = tolower(c);
switch(c)
{
case 'a' : return a;
case 'e' : return e;
case 'i' : return i;
case 'o' : return o;
case 'u' : return u;
default : return 0;
}
}
//=================
int main()
{
// static variables will be initialized to zero by the system
static int tally[6][6]; // allow for zero [first vowel][last vowel]
char sentence[] = "moot moon mean affair moon moUse";
int beg = 0, end; // first vowel, last vowel. Avoid l looks like 1
problem
for(int i=0; sentence[i]; i++)
{
end = classify(sentence[i]);
if(beg)
tally[beg][end]++;
beg = end;
}
// done. show output
for(int i=1; i<6; i++)
{
for(int j=1; j<6; j++)
cout << tally[i][j];
cout << endl;
}
cin.get();
cin.get();
}


  #5  
Old May 27th, 2006, 05:25 PM
Tomás
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

Prof.Stanley posted:
[color=blue]
> HELLO ALL I AM TRYING TO PUT UP A PROGRAM THAT DETECTS DOUBLE VOWELS
> AFTER RECIEVING AN INPUT STRING; MY MAIN PROBLEM LIES IN THE INPUT CAN
> SOMEBODY KINDLY HELP DETECT ANY SYNTAX OR SEMANTIC ERRORS:[/color]


I already told you how disgusting and retarded your code is, and I even
took the time to write you much nicer code. How about you read the replies
to your posts before you just go and post some more.


-Tomás
  #6  
Old May 27th, 2006, 08:35 PM
Martin Jørgensen
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

Prof.Stanley wrote:[color=blue]
> HELLO ALL I AM TRYING TO PUT UP A PROGRAM THAT DETECTS DOUBLE VOWELS
> AFTER RECIEVING AN INPUT STRING; MY MAIN PROBLEM LIES IN THE INPUT CAN
> SOMEBODY KINDLY HELP DETECT ANY SYNTAX OR SEMANTIC ERRORS:
>
> HERE IS THE CODE:[/color]

I CANNOT HEAR YOU.... THERE'S SO MUCH NOISE IN HERE, THAT I MUST TURN ON
THE CAPS LOCK KEY, JUST SO OTHERS CAN HEAR ME SHOUTING.


Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
  #7  
Old May 28th, 2006, 02:55 AM
benben
Guest
 
Posts: n/a
Default Re: SYNTAX AND SEMANTICS

OP's problem is not just his style but his algorithm. Scanning for
double-vowels are simple enough to be squeezed in a 30- lines function,
even if regular expression is not used.

A simple solution is to use a stack and a map. Push vowels to the stack
until a consonant is found, then pop the stack and add the record to a
map counter.

Regards,
Ben
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.