program main
implicit none
write(*, *) mod(139, 10) ! 139 - 10*(int(139 // 10)) => 139 - 10*int(13.9) => 139 - 130 = 9
write(*, *) mod(139, -10) ! 139 - (-10)*(int(139 // -10) => 139 + 10*int(-13.9) => 139 + (-130) = 9
write(*, *) mod(-139, 10) ! -139 - 10*(int(-139 // 10)) => -139 - 10*int(-13.9) => -139 + 130 = -9
write(*, *) mod(-139, -10) ! -139 - (-10)*(int(-139 // -10)) => -139 - (-10)*(int(13.9)) => -139 + 130 = -9
end program
9
9
-9
-9
请按任意键继续. . .
print(139 % 10) # 139 - 10*(int(139 // 10)) => 139 - 10*int(13.9) => 139 - 130 = 9
print(139 % -10) # 139 - (-10)*(int(139 // -10) => 139 + 10*int(-13.9) => 139 + (-140) = -1
print(-139 % 10) # -139 - 10*(int(-139 // 10)) => -139 - 10*int(-13.9) => -139 + 140 = 1
print(-139 % -10) # -139 - (-10)*(int(-139 // -10)) => -139 - (-10)*(int(13.9)) => -139 + 130 = -9
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
================ RESTART: C:/Users/Administrator/Desktop/fuck.py ===============
9
-1
1
-9
>>>
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%d\n", 139 % 10);
printf("%d\n", 139 % -10);
printf("%d\n", -139 % 10);
printf("%d\n", -139 % -10);
return 0;
}
9
9
-9
-9
请按任意键继续. . .
liudy02 发表于 2020-8-3 11:00
python脚本名字是亮点……
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |