#include <iostream> using namespace std; int main() { //取模运算,就是求余数,运算符% int a = 10; int b = 3; cout << a % b << endl; int a2 = 10; int b2 = 20; cout << a2 % b2 << endl;//结果为10; int a3 = 10; int b3 = 0; //cout << a3 % b3 << endl;//除数不能是0; //两个小数不能做取模运算 double d1 = 3.14; double d2 = 1.2; //cout<<d1%d2<<endl;必须是整数 system("pause"); return 0; }