int main(){
char ch;
cout << "Input char (end - x)\n ";
do {
cout << ":"; //
cin >> ch; // <enter>
} while (ch!= 'x'); //( )
cout << " <x> -- end " << endl;
_getch(); // <enter>
return 0;
}
while (( ch = getche() )!= '\r') // <enter>
{ if ch == ' ' ..
else }
:
getchar() <enter>
getche() c <enter>
-----------------------------------------------------------------------------------------
( ) [8]
, , , , ( ) . , , , () . . .
++ :
try , ;
catch, try, , ( ;
throw catch ( catch, MFC, .
, , :
//
try
{
.....
if (..)
throw; //
.....
}
//
catch (...)
{
.....
}
try . if . , throw catch, . try, catch .
catch ( ) , , . try- , catch-, (.. catch- ). try- , catch-.
|
|
try , throw, try, throw return try catch.
throw try , , try, , , try. . try, .
( ; 0, ).
# include <iostream> // / ++
using namespace std; //
int main()
{
int numerator; //
int denominator; //
int result=99999999;
Try
{
cout << "Enter two integers: ";
//
while(! (cin >> numerator) ||! (cin >> denominator))
{
cout << "Enter two integers: ";
cin.clear(); // cin.ignore(cin.rdbuf()->in_avail()); //
}
if (denominator == 0)
throw " The denominator is 0 ";
//
//
result = numerator / denominator;
// numerator < denominator, result ==0, .. int
if (result == 0)
throw "The quotient is 0 "; //
cout << "The quotient is: " << result << endl; //
} // try
//
catch (const char * s)
{
cout << "Exception occurred: " << s << numerator << " " <<
denominator << " " << result << endl;
} // catch
system("pause");
return 0; //
}
.
catch . catch- , , . catch- , 0 0 .
try- catch- .
|
|
catch- .
catch- try- .
. .
:
Enter two integers: 1 q
Enter two integers: q 2
Enter two integers: 1.2 3
Enter two integers: 3 4.2
Exception occurred: The quotient is 0 3 4 0 !!!
Enter two integers: 1 4
Exception occurred: The quotient is 0 1 4 0 !!!
Enter two integers: 4 0
Exception occurred: The denominator is 0 4 0 99999999 !!!
Enter two integers: 4 2
The quotient is: 2
-----------------------------------------------------------------------------------------
( 2.2)
a, b, c, d. a £ b £ c £ d, , a > b > c > d, , .
int main()
{
Double a, b, c, d;
printf(" Input a, b, c, d:\n");
scanf_s("%lf %lf %lf %lf", &a, &b, &c, &d);
printf("a = %lf; b = %lf; c = %lf; d = %lf;\n", a, b, c, d);
if (a <= b && b <= c && c <= d)
{a = d; b = d; c = d;}
else if (a > b && b > c && c > d)
; // !!!
else {a = a * a; b = b * b; c = c * c;}
printf("a = %lf; b = %lf; c = %lf; d = %lf; \n ", a, b, c, d);
_getch();
return 0;
}
-----------------------------------------------------------------------------------------