( ):
// 31.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char n_reg, v_reg, c;
c='b' + '%' - '!'; //f
cout << c << endl; //102( 'f') = 98( 'b')+37( '%')-33('!')
cout << "Input char \'A\' - \'Z\' " <<endl;
cin >> v_reg;
n_reg = v_reg+32; //32 ,
//
cout << v_reg << " " << n_reg << '\n';
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
!!! <= >= == != . , ( ).
!!! = == .
// 32.
#include <iostream> //
#include <conio.h>
using namespace std;
int main()
{
int numb;
cout << "Enter a number: ";
cin >> numb;
cout << "numb < 10 = " << (numb < 10) << endl;
cout << "numb > 10 = " << (numb > 10) << endl;
cout << "numb == 10 = " << (numb == 10) << endl;
_getch();
return 0;
}
:
Enter a number: 1
numb < 10 is 1
numb > 10 is 0
numb == 10 is 0
Enter a number: 10
numb<10 is 0
numb>10 is 0
numb==10 is 1
-----------------------------------------------------------------------------------------
!!! k = a + (i ++) d * (-- j);
:
-- j;
k = a + i d * j;
i ++;
!!!
-----------------------------------------------------------------------------------------
int i=2, j=0;
i++;
cout << i << endl; // 3
--i;
cout << i << endl; // 2
-----------------------------------------------------------------------------------------
// 33.
:
#define PRINT(int) printf("%d\n", int)
x = y = 1;
z = x++ - 1; PRINT(x); PRINT(z); | z=0; x=2 |
z += -x++ + ++y; PRINT(x); PRINT(z); | z= 0+(-2)+ 2=0; x=3; y=2; |
z = x/ ++x; PRINT(z); | - |
|
|
-----------------------------------------------------------------------------------------
// 34.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{ //
float x = 2;
x = ++x * 4;
cout << x << endl; //12
x = 2;
x = x++ * 4;
cout << x << endl; //9
x = 2;
x = --x * 4;
cout << x << endl; // 4
x = 2;
x = x-- * 4;
cout << x << endl; // 7
_getch();
return 0;
}
!!!
//
// 35.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
float x = 2;
++x = x * 4;
cout << x << endl; // 12
// x++ = x * 4; error!!! left operand must be l-value
cout << x << endl;
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// 36.
//
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int var = 10;
cout << var << endl; // 10
var *= 2;
cout << var-- << endl; // 20!!!
cout << var << endl; // 19
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// 37.
//
#include <stdio.h>
#include <conio.h>
int main()
{
int x = 2, y = 1, z = 0;
x =((x && y) || z);
printf("%d\n", x); //1
printf("%d\n\n", x ||!y &&z); //1
_getch();
x = y = z = 1;
printf("%d\n", ++x || ++y && ++z); //1
printf("%d\n", x); //2
printf("%d\n", y); //1
printf("%d\n", z); //1
_getch();
x = y = z = 1;
printf("%d\n", ++x && ++y || ++z); //1
printf("%d\n", x); //2
printf("%d\n", y); //2
printf("%d\n", z); //1
_getch();
x = y = z = 1;
printf("%d\n", ++x && ++y && ++z); //1
printf("%d\n", x); //2
printf("%d\n", y); //2
printf("%d\n", z); //2
_getch();
x = y = z = -1;
printf("%d\n", ++x && ++y || ++z); //0
printf("%d\n", x); //0
printf("%d\n", y); //-1
printf("%d\n", z); //0
_getch();
x = y = z = -1;
printf("%d\n", ++x || ++y && ++z); //0
printf("%d\n", x); //0
printf("%d\n", y); //0
printf("%d\n", z); //-1
_getch();
x = y = z = -1;
printf("%d\n", ++x && ++y && ++z); //0
|
|
printf("%d\n", x); //0
printf("%d\n", y); //-1
printf("%d\n", z); //-1
_getch();
return 0;
}
-----------------------------------------------------------------------------------------