Home > Back-end >  The C programming
The C programming

Time:10-02

Chapter 6 programming practice
1,
#include
#include

Int main ()
{
using namespace std;

char ch;
Cin. Get (ch);

While (ch! )
='@'{
If (isdigit (ch))
Cin. Get (ch);
The else
{
If (islower (ch))
Ch=toupper (ch);
The else
Ch=tolower (ch);
CoutCin. Get (ch);
}
}
system("pause");
return 0;
}


2,
#include

Int main ()
{
using namespace std;

Double sum=0;
Double business=0;
Double num [10].
Int I=0, total=0;

Double TMP.

While (cin> Tmp& & I<10)
{
Num=[I] TMP;
The sum + num=[I];
+ + I;
}

If (I.=0)
Business=sum/I;

For (int j=0; JIf (num [j] & gt; Business)
+ + total;

Cout<& lt;" For the average of these digital "& lt; Cout<& lt;" And there are "& lt;
system("pause");
return 0;
}


3,
#include

Int main ()
{
using namespace std;

Cout<& lt;" Both Please enter one of the following choices: \ n "
<& lt;" C) carnivore p) pianist \ n
"<& lt;" T) tree g) game \ nf \ n ";

Cout<& lt;" Both Please enter a, c, p, t, or g: ";

char ch;
cin> Ch;

While (ch!='c' & amp; & Ch!='p' & amp; & Ch!='t' & amp; & Ch! )
='g'{
Cout<& lt;" Both Please enter a, c, p, t, or g: ";
cin> Ch;
}

The switch (ch)
{
Case 'c' :
Cout<& lt;" A maple is A tree. \ n ";
break;
Case: 'p'
Cout<& lt;" A maple is A pianist. \ n ";
break;
In case the 't' :
Cout<& lt;" A maple is A tree. \ n ";
break;
Case 'g' :
Cout<& lt;" A maple is A game. \ n ";
}

system("pause");
return 0;
}

CodePudding user response:

The original poster is to ask what?
  • Related