#include
void main(void)
{ int a,b,sum4,sum6,mul;
for(a=1;a<100;a++)
for(b=1;b<100;b++)
{sum4=4*a-6*b;
sum6=6*a-15*b;
mul=a*(a-b)*(a-2*b)*(a-3*b);
if(sum4==26 && mul==880)
{printf("该数列前4项之和是 %d\n该数列前4项之积为 %d\n\n",sum4,mul);
printf("该等差数列首项为 %d\n公差为 %d\n前六项之和为 %d\n",a,b,sum6);
}
}
}
参考,改变变量即可
void main(){
int a,d;
for (a=1;a<=4;a++)
for (d=1;d<=6;d++)
if (6*a+d+2d+3d+4d+5d==26 && a*(a+d)*(a+2*d)*(a+3*d)==880) printf("%d %d \n", a,d);
}