|
From: Adam J. <aj...@i-...> - 2007-07-21 13:02:57
|
>>You wrote:
>>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
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 =0, eCnt =0, iCnt =0, oCnt =0, uCnt =0, consonantCnt =0,
spaceCnt =0;
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 are
intended solely for the use of the individual(s) named on this transmission.
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 advise
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 another
one:
with this initialization
int aCnt =0, eCnt =0, iCnt =0, oCnt =0, uCnt =0, consonantCnt =0, spaceCnt
=0;
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 =0, eCnt =0, iCnt =0, oCnt =0, uCnt =0, consonantCnt =0,
> spaceCnt =0;
> >> 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 statement
> inside of your while loop. So what is happing is that the only line in
your
> program being executed is
>
> >> while ( cin >> ch )
>
> You need to add the brackets after the while loop and enclose the switch
> 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 comand
> > >>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 the
> > 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 see
> > 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 console
> window.
> >
> > -Adam Jones
> >
> >
> >
> > ----------------------------------------------------------------------
> > --- This SF.net email is sponsored by DB2 Express Download DB2 Express
> > C - the FREE version of DB2 express and take control of your XML. No
> > 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 canone
Telecom
http://click.libero.it/infostrada
|