若x mod 2 =1, x mod 3 = 2, x mod 5 = 4, x mod 6 = 5, x mod 7 =0;求最小解
源码如下:
1: #include <string.h>
2: #include <stdio.h>
3:
4: int main()
5: {
6: int x = 7, i, res, flag = 0;
7:
8: for (i=1; i<=100; i++)
9: {
10: if ((x%2 == 1) && (x % 3 == 2) && (x % 5 == 4) && (x % 6 ==5))
11: {
12: res = x;
13: flag = 1;
14: break;
15: }
16: x = 7 * (i + 1);
17: }
18:
19: if (flag == 1)
20: printf("the result is %d", res);
21: else
22: printf("no result");
23:
24: return 0;
25: }