|
From: danilo\.ferrarotti\@libero\.it <dan...@li...> - 2007-10-03 15:28:57
|
Sorry,
it's possible to have only the last counts in output and not the entire i=
plementation of the wovels?
thanks
Danilo
---------- Initial Header -----------
>From : dev...@li...
To : "Dev Cpp MailingLinst" dev...@li...
Cc :
Date : Sat, 21 Jul 2007 09:02:46 -0400
Subject : [Dev-C++] FW: Question
> >>You wrote:
> >>every output is equal to 0. I can't solve how to make the count of th=
e
> vocals and conconant. Do you have a solution
>
> Please make sure your code looks like this, and it should work.
>
> #include <iostream>
> #include <ctype.h>
>
> using namespace std;
>
> int main()
> {
> char ch;
> int aCnt =3D0, eCnt =3D0, iCnt =3D0, oCnt =3D0, uCnt =3D0, consonan=
tCnt =3D0,
> spaceCnt =3D0;
>
> while ( cin >> ch )
> { <- Note where I added the brackets one here....
> switch ( ch )
> {
> case 'a': case 'A':
> ++aCnt;
> break;
> case 'e': case 'E':
> ++eCnt;
> break;
> case 'i': case 'I':
> ++iCnt;
> break;
> case 'o': case 'O':
> ++oCnt;
> break;
> case 'u': case 'U':
> ++uCnt;
> break;
> case ' ':
> ++spaceCnt;
> default:
> if ( isalpha( ch ))
> ++consonantCnt;
> break;
> }
> cout << " numero di a:" << aCnt << '\n';
> cout << " numero di e:" << eCnt << '\n';
> cout << " numero di i:" << iCnt << '\n';
> cout << " numero di o:" << oCnt << '\n';
> cout << " numero di u:" << uCnt << '\n';
> cout << " numero di consonanti:" << consonantCnt << '\n';
> cout << " numero di sapzi:" << spaceCnt << '\n';
> } <- The other bracket here.....
>
> return 0;
> }
>
> -Adam Jones
>
>
>
> CONFIDENTIALITY NOTE:
> This e-mail and its attachments contain confidential information and ar=
e
> intended solely for the use of the individual(s) named on this transmis=
sion.
> If you are not the intended recipient, you are notified that disclosing=
,
> copying, distributing or taking any action in reliance on the contents =
of
> this information is strictly prohibited. If you are not the intended
> recipient of this e-mail please destroy this message immediately and ad=
vise
> the sender of the same.
>
> -----Original Message-----
> From: dan...@li... [mailto:dan...@li...] =
> Sent: Friday, July 20, 2007 8:47 AM
> To: ajones
> Subject: Re: [Dev-C++] Question
>
> I put the bracket as you said, and i solved the problem. Now appers ano=
ther
> one:
>
> with this initialization
>
> int aCnt =3D0, eCnt =3D0, iCnt =3D0, oCnt =3D0, uCnt =3D0, consonantCnt=
=3D0, spaceCnt
> =3D0;
>
> every output is equal to 0. I can't solve how to make the count of the
> vocals and conconant. Do you have a solution
>
> Thanks
>
> Danilo
>
> ---------- Initial Header -----------
>
> >From : dev...@li...
> To : "dev-c++ devc++" dev...@li...
> Cc :
> Date : Thu, 19 Jul 2007 18:33:01 -0400
> Subject : Re: [Dev-C++] Question
>
>
>
>
>
>
>
> > The code you posted is listed below:
> >
> > >>#include <iostream>
> > >>#include <ctype.h>
> > >>using namespace std;
> > >>int main()
> > >>{
> > >> char ch;
> > >> int aCnt =3D0, eCnt =3D0, iCnt =3D0, oCnt =3D0, uCnt =3D0, cons=
onantCnt =3D0,
> > spaceCnt =3D0;
> > >> while ( cin >> ch )
> > >> switch ( ch )
> > >> {
> > >> case 'a': case 'A':
> > >> ++aCnt;
> > >> break;
> > >> case 'e': case 'E':
> > >> ++eCnt;
> > >> break;
> > >> case 'i': case 'I':
> > >> ++iCnt;
> > >> break;
> > >> case 'o': case 'O':
> > >> ++oCnt;
> > >> break;
> > >> case 'u': case 'U':
> > >> ++uCnt;
> > >> break;
> > >> case ' ':
> > >> ++spaceCnt;
> > >> default:
> > >> if ( isalpha( ch ))
> > >> ++consonantCnt;
> > >> break;
> > >> }
> > >> cout << " numero di a:" << aCnt << '\n';
> > >> cout << " numero di e:" << eCnt << '\n';
> > >> cout << " numero di i:" << iCnt << '\n';
> > >> cout << " numero di o:" << oCnt << '\n';
> > >> cout << " numero di u:" << uCnt << '\n';
> > >> cout << " numero di consonanti:" << consonantCnt << '\=
n';
> > >> cout << " numero di sapzi:" << spaceCnt << '\n';
> > >> return 0;
> > >>}
> >
> > The problem with your code is that you do not enclose the switch stat=
ement
> > inside of your while loop. So what is happing is that the only line i=
n
> your
> > program being executed is
> >
> > >> while ( cin >> ch )
> >
> > You need to add the brackets after the while loop and enclose the swi=
tch
> > statement. Once you do that, it should work,
> >
> > while ( cin >> ch )
> > { <--Add this openning bracket here
> > switch ( ch )
> > {
> > case 'a': case 'A':
> > .
> > .
> > .
> > .
> > } <-- Add closing bracket here.
> >
> > -Adam Jones
> >
> > -----Original Message-----
> > From: dan...@li... [mailto:dan...@li...=
]
> > Sent: Thursday, July 19, 2007 9:57 AM
> > To: ajones
> > Subject: Re: [Dev-C++] Question
> >
> > This is the source code
> >
> > many thanks
> >
> > Danilo
> >
> > ---------- Initial Header -----------
> >
> > >From : dev...@li...
> > To : "dev-c++ devc++" dev...@li...
> > Cc :
> > Date : Thu, 19 Jul 2007 08:59:23 -0400
> > Subject : Re: [Dev-C++] Question
> >
> >
> >
> >
> >
> >
> >
> > > >>Hello,
> > >
> > > >>I have a problem with this program: when a give the execute coman=
d
> > > >>the
> > > *.exe window opens but after I give the characters to switch as You=
> > > can see on the While comand : >>while ( cin >> ch ) I can't make th=
e
> > > execution of the program.
> > >
> > > >>There's a specific comand to give on the *.exe window for running=
> > > >>the
> > > execution after writing on it?
> > >
> > > >>Many Thanks
> > >
> > > >>Danilo
> > >
> > > Unfortunately I am not sure what you are asking. If the program is =
not
> > > large, post the source code. How do you know that the code is not
> > running??
> > > Maybe it is running, but you haven't paused executive so you can se=
e
> > > the output. If you don't pause the executive the cin will get the
> > > input, the program will do what it has to do and then close the con=
sole
> > window.
> > >
> > > -Adam Jones
> > >
> > >
> > >
> > > -------------------------------------------------------------------=
---
> > > --- This SF.net email is sponsored by DB2 Express Download DB2 Expr=
ess
> > > C - the FREE version of DB2 express and take control of your XML. N=
o
> > > limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________
> > > Dev-cpp-users mailing list
> > > Dev...@li...
> > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> > >
> >
> >
> > ------------------------------------------------------
> > Leggi GRATIS le tue mail con il telefonino i-modeT di Wind
> > http://i-mode.wind.it/
> >
> >
> >
> > ---------------------------------------------------------------------=
----
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
>
> ------------------------------------------------------
> Scegli infostrada: ADSL gratis per tutta l'estate e telefoni senza cano=
ne
> Telecom
> http://click.libero.it/infostrada
>
>
> -----------------------------------------------------------------------=
--
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> =0A=0A=0A------------------------------------------------------=0ALeggi=
GRATIS le tue mail con il telefonino i-mode=99 di Wind=0Ahttp://i-mode.w=
ind.it/=0A
|