#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h> // /ࠠ
#include <conio.h> // _getch()
int main(){
double x = 1.79, y, r1, r2, r3, r4;
r1 = cos(x);
r2 = pow((exp(r1) + x * x + sin(x)),.25);
r3 = (sin(M_PI * x * x) + log(x * x));
r4 = pow(r3, r1);
y = r2 * r4;
printf(" \n for x = %8.6lf y = %10.6lf \n ", x, y);
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
π M_PI
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream> // / ++
using namespace std; //
int main(){
double x = 1.79, y;
y = cos(x)+ M_PI;
cout << " \n for x = ", x, " y = ", y) << endl;
system("pause");
return 0;
}
-----------------------------------------------------------------------------------------
π
# define _USE_MATH_DEFINES
# include <cmath>
# include <iostream> // / ++
using namespace std; //
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
int main(){
double x = 1.79, y;
y = cos(x)+ M_PI;
cout << " \n for x = ", x, " y = ", y) << endl;
system("pause");
return 0;
}
-----------------------------------------------------------------------------------------
( 1.1) [7]
, , . , .
, 1 20:
int r;
Do
{
cout << "input 1 <= r <=20" << endl;
cin >> r;
} while (r < 1 || r > 20);
-----------------------------------------------------------------------------------------
, 13:
int r;
Do
{
cout << "input r >0, r!=13: " <<endl;
cin >> r;
} while (r < 0 || r == 13);
-----------------------------------------------------------------------------------------
while 10 25 rez:
|
|
int i=1, rez=0;
while (i++ <= 10 && rez!= 25)
{
cout << "input rez=25"<<endl;
cin >> rez;
}
-----------------------------------------------------------------------------------------
unsigned char
, , :
// unsigned char
#include <LIMITS.H> // UCHAR_MAX
unsigned char uch;
unsigned int uchar; // unsigned int
do {
cout << "input unsigned char:" << endl;
cin. clear (); //
cin. sync (); //
/* cin.sync() ,
cin. ignore (cin. rdbuf ()-> in _ avail ());
*/
cin >> uchar;
} while(uchar < 0 || uchar > UCHAR _ MAX);
// unsigned char
uch = uchar;
cout << "ok " << uch << endl;
-----------------------------------------------------------------------------------------