Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Primer on speech recognition Pin
LFUebel20-Oct-09 14:44
LFUebel20-Oct-09 14:44 
GeneralRe: Primer on speech recognition Pin
Dewald20-Oct-09 19:17
Dewald20-Oct-09 19:17 
GeneralRe: Primer on speech recognition Pin
LFUebel21-Oct-09 3:49
LFUebel21-Oct-09 3:49 
GeneralRe: Primer on speech recognition Pin
Dewald21-Oct-09 4:55
Dewald21-Oct-09 4:55 
GeneralRe: Primer on speech recognition Pin
LFUebel21-Oct-09 5:35
LFUebel21-Oct-09 5:35 
GeneralRe: Primer on speech recognition Pin
LFUebel23-Oct-09 0:37
LFUebel23-Oct-09 0:37 
GeneralRe: Primer on speech recognition Pin
transoft21-Oct-09 6:47
transoft21-Oct-09 6:47 
QuestionIncrement gone wrong, pls help [modified] Pin
songryong20-Oct-09 7:50
songryong20-Oct-09 7:50 
Im having problem with the output of this program that i made that supposed to count the numbers of successful a's and b's based on the pattern indicated in my condition.

*********************************************************************

#include<iostream>
using namespace std;
int main()
{
int lookahead;
int q1=0, q2=0, q3=0, q4=0, q5=0, q6=0;
int count_a=0;
int count_b=0;

while((lookahead = getchar())!='.')
{
switch(lookahead)
{
case 'a':{
if(q1==0 && q2==0 && q3==0 && q4==0 && q5==0 && q6==0) // 1 give a ~~> 2
{
q1=0;
q2=1;
q3=0;
q4=0;
q5=0;
q6=0;
}
else if ( q1==0 && q2==1 && q3==0 && q4==0 && q5==0 && q6==0 ) // 2 give a ~~> 3
{
q1=0;
q2=1;
q3=1;
q4=0;
q5=0;
q6=0;
}
else if ( q1==0 && q2==1 && q3==1 && q4==0 && q5==0 && q6==0) // 3 give a ~~> 6 then a++
{

q1=0;
q2=0;
q3=0;
q4=0;
q5=0;
q6=0;
count_a++;
}
else if ( q1==0 && q2==0 && q3==0 && q4==1 && q5==0 && q6==0) // if press a while in 4 2==1
{

q1=0;
q2=1;
q3=0;
q4=0;
q5=0;
q6=0;
}
else if (q1==0 && q2==0 && q3==0 && q4==1 && q5==1 && q6==0) // if press a while in 4==1 && 5==1 ~~> 2==1
{

q1=0;
q2=1;
q3=0;
q4=0;
q5=0;
q6=0;
}

}
break;
case 'b':{
if(q1==0 && q2==0 && q3==0 && q4==0 && q5==0 && q6==0) // 1 give b ~~> 4
{
q1=0;
q2=0;
q3=0;
q4=1;
q5=0;
q6=0;
}
else if ( q1==0 && q2==0 && q3==0 && q4==1 && q5==0 && q6==0 ) // 4 give b ~~> 3
{
q1=0;
q2=0;
q3=0;
q4=1;
q5=1;
q6=0;
}
else if ( q1==0 && q2==0 && q3==0 && q4==1 && q5==1 && q6==0) // 5 give b ~~> 6 then a++
{

q1=0;
q2=0;
q3=0;
q4=0;
q5=0;
q6=0;
count_b++;
}
else if ( q1==0 && q2==1 && q3==0 && q4==0 && q5==0 && q6==0) // if press b while in 2 4==1
{

q1=0;
q2=0;
q3=0;
q4=1;
q5=0;
q6=0;
}
else if (q1==0 && q2==1 && q3==1 && q4==0 && q5==0 && q6==0) // if press a while in 2==1 && 3==1 ~~> 4==1
{

q1=0;
q2=0;
q3=0;
q4=1;
q5=0;
q6=0;
}

}
break;

default:{
q1=0;
q2=0;
q3=0;
q4=0;
q5=0;
q6=0;
}

}

cout<<"\n count_a :"<<count_a;
cout<<"\n count_b :"<<count_b;

}
return 0;

}



*****************************************************************

when i didnt enter any letter the output is:

count_a: 0
count_b: 0

when the letter increase the number of count display multiplies too and it shouldnt'..

like this; input words "aaa"

count_a: 0
count_b: 0
count_a: 0
count_b: 0
count_a: 1
count_b: 0
count_a: 1
count_b: 0

Where do you think is the problem on my codes?



modified on Tuesday, October 20, 2009 2:00 PM

AnswerRe: Increment gone wrong, pls help Pin
«_Superman_»20-Oct-09 7:58
professional«_Superman_»20-Oct-09 7:58 
GeneralRe: Increment gone wrong, pls help Pin
songryong20-Oct-09 8:01
songryong20-Oct-09 8:01 
AnswerRe: Increment gone wrong, pls help Pin
Maximilien20-Oct-09 8:19
Maximilien20-Oct-09 8:19 
GeneralRe: Increment gone wrong, pls help Pin
songryong20-Oct-09 8:31
songryong20-Oct-09 8:31 
GeneralRe: Increment gone wrong, pls help Pin
David Crow20-Oct-09 9:29
David Crow20-Oct-09 9:29 
GeneralRe: Increment gone wrong, pls help Pin
songryong20-Oct-09 9:34
songryong20-Oct-09 9:34 
GeneralRe: Increment gone wrong, pls help Pin
David Crow20-Oct-09 9:38
David Crow20-Oct-09 9:38 
GeneralRe: Increment gone wrong, pls help Pin
songryong20-Oct-09 9:47
songryong20-Oct-09 9:47 
QuestionWindows service as ActiveX control/component Pin
shatterstar645720-Oct-09 7:14
shatterstar645720-Oct-09 7:14 
AnswerRe: Windows service as ActiveX control/component Pin
transoft20-Oct-09 11:38
transoft20-Oct-09 11:38 
GeneralRe: Windows service as ActiveX control/component Pin
shatterstar645720-Oct-09 11:58
shatterstar645720-Oct-09 11:58 
GeneralRe: Windows service as ActiveX control/component Pin
transoft20-Oct-09 12:09
transoft20-Oct-09 12:09 
QuestionRegistry problem Pin
Tomas(cz)20-Oct-09 6:45
Tomas(cz)20-Oct-09 6:45 
AnswerRe: Registry problem Pin
Richard MacCutchan20-Oct-09 6:52
mveRichard MacCutchan20-Oct-09 6:52 
GeneralRe: Registry problem Pin
Tomas(cz)20-Oct-09 22:13
Tomas(cz)20-Oct-09 22:13 
QuestionBOOT Failure error Pin
KarthikonIT20-Oct-09 6:44
KarthikonIT20-Oct-09 6:44 
AnswerRe: BOOT Failure error Pin
«_Superman_»20-Oct-09 7:25
professional«_Superman_»20-Oct-09 7:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.