顶顶顶 学习了
The Best
#include<stdio.h> int main() { int an; int n; int s = 100; int a1 = 4; int d; int i; for(an = 96;an >= 4;an --) { if((2 * s) % (a1 + an) == 0) { n = (2 * s) / (a1 + an); if((an - a1) % (n - 1) != 0 && (an - a1) != 0) continue; d = (an - a1) / (n - 1); for(i = 0;i < n;i ++) printf("%d ",a1 + i * d); printf("\n"); } } return 0; }
# include <stdio.h> int main() { int sum, num, i; int sum1, num1; for (i=0; i<=96; i++) { int c; c = i; sum = 0; num = 4; while (sum < 100) { sum += num; num += c; // printf("%d ", sum); // printf("%d ", num); } // printf("%d ", sum); // printf("\n"); if (sum > 100) continue; else if (sum <= 100) { sum1 = 0; num1 = 4; printf("100 = "); while (sum1 < 100) { if (num1 < 100) printf("%d + ", num1); sum1 += num1; num1 += c; //printf("%d ", num1); } printf("\n"); } } return 0; } /* vc中的结果: 100 = 4+ 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 100 = 4+ 12 + 20 + 28 + 36 + 100 = 4+ 18 + 32 + 46 + 100 = 4+ 96 Press any key to continue */大神:六楼那个有点小问题,我只是小小修改了一下但是后面老是多个+,你可以帮忙看看吗?