#!/usr/bin/python #coding=utf-8 #好好学习,天天向上 number = input("please enter a number:") number=int(number) if number % 2 ==0: print(f"the number {number} is a 偶数") else: print(f"the number {number} is a 奇数")
头文件:#include <math.h> fmod() 用来对浮点数进行取模(求余),其原型为: double fmod (double x); 设返回值为 ret,那么 x = n * y + ret,其中 n 是整数,ret 和 x 有相同的符号,而且 ret 的绝对值小于 y 的绝对值.如果 x = 0,那么 ret = NaN. fmod 函数计算 x 除以 y 的 f 浮点余数,这样 x = i*y + f,其中 i 是整数,f 和 x 有相同的符号,而且 f 的绝对值小于
1.什么是运算符重载 运算符重载是一种函数重载. 运算符函数的格式:operatorop(argument-list)例如,operator+()重载+运算符.其中的op,必须是有效的C++运算符,如operator@()会报错,因为C++中没有@运算符. 2.重载运算符的使用 如下例所示: class Test { public: Test operator+(Test &test); } 调用运算符函数的方式有两种:Test t1;Test t2;1)普通函数调用Test t3 = t1.o