加减乘除运算
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <iostream>
using namespace std;
int main()
{
//加减乘除
int a1 = 300;
int b1 = 3;
cout << a1 + b1 << endl;
cout << a1 - b1 << endl;
cout << a1 * b1 << endl;
cout << a1 / b1 << endl;
cout << a1 % b1 << endl;
int a2 = 10;
int b2 = 20;
cout << a2 / b2 << endl;
//int a3 = 10;
//int b3 = 0;
//cout << a3 / b3 << endl;
double d1 = 0.5;
double d2 = 0.22;
cout << d1 / d2 << endl;
}
|
注:%为取余运算,可以得出小数。double为双精度浮点型