#include <iostream>
//运算符
using namespace std;
int main () {
int a = 9;
int b = 6;
cout<<"这是加法:"<<a+b<<endl;
cout<<"这是减法:"<<a-b<<endl;
cout<<"这是乘法:"<<a*b<<endl;
cout<<"这是取整(只要小数点前面的数字):"<<a/b<<endl;
cout<<"这是正常的除法:"<<a*1.0 / b <<endl;
a = 1000000000;
b = 10000000;
cout<<"这时a*b会超出int的范围:"<<a*b<<endl;
cout<<"可以这样子操作换一个类型:"<<(long long)a*b<<endl;
//字符也可以进行运算
char A = 'A';
cout<<"这是正常的A:"<<A<<endl;
A += 1;
cout<<"这是A+1:"<<A<<endl;
return 0;
}
这是输出结果
标签:std,cout,int,namespace,c++,运算符,main From: https://blog.csdn.net/m0_63056769/article/details/142342977