取模运算
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 10931 | Accepted: 6618 |
Description
编写一个C函数mod(int n, int m),实现取模运算%
Input
输入包含多行数据
每行数据是两个整数a, b (1 <= a, b <= 32767)
数据以EOF结束
Output
于输入的每一行输出a%b
Sample Input
5 3
100 2
Sample Output
2
0
#include <stdio.h> int mod(int n, int m){
// if(n >= m)
// n = n - n / m * m;
// return n;
return n % m;
} int main(){
int m, n;
while(scanf("%d %d", &m, &n) != EOF){
printf("%d\n", mod(m, n));
}
return ;
}