#include<iostream>usingnamespace std;intmain(){//取模运算实质就是求余数,两个小数是不可以做取模运算的int a1 =10;int b1 =3;
cout << a1 % b1 << endl;//递增,递减运算符// int b =2;int c =10;int d =10;//1.前置递增,前置递增在运算中,先做自身的递增,再参与运算++b;
cout << b << endl;//3int f =++c *10;
cout <<"f的值为:"<< f << endl;//110
cout << c << endl;//11//2.后置递增,后置递增在运算中,先参与运算,再做自身的递增
b++;
cout << b << endl;//4int e = d++*10;
cout <<"e的值为"<< e << endl;//100
cout << d << endl;//11system("pause");return0;}
赋值运算符
#include<iostream>usingnamespace std;intmain(){//赋值运算符int a =10;//=
a =100;
cout <<"a="<< a << endl;//100//+=
a =10;
a +=2;//相当于a=a+2;
cout <<"a+=2 ="<< a << endl;//12//-=
a =10;
a -=2;//相当于a=a-2;
cout <<"a-=2 ="<< a << endl;//8//*=
a =10;
a *=2;//相当于a=a*2;
cout <<"a*=2 ="<< a << endl;//20// /=
a =10;
a /=2;//相当于a=a/2;
cout <<"a/=2 ="<< a << endl;//5//%=
a =10;
a %=2;//相当于a=a%2;
cout <<"a%=2 ="<< a << endl;//0system("pause");return0;}