You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
590 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
/**
+
n=3
MOD0,1,2,0,1,2
MOD 0 1 2 0 1 2 0 1 2
@ @ @ @ @ @ @ @ @
a -3 -2 -1 0 1 2 3 4 5
*/
int MOD(int a, int b) {
return (a % b + b) % b; //配合数组下标从0开始合适
}
int main() {
int n = 5;
for (int a = -4; a <= 2; a++) {
cout << "a=" << a << " MOD=" << MOD(a, n) << endl;
}
return 0;
}