本帖最后由 tom075395 于 2012-10-13 15:06 编辑
等差
首项=2 项差=3 项数自设
要出到3的倍数 出3的倍数有多少 少过20的有项数有多少
int a,d,n,p,x,q;
a=2;
scanf("%d",&n);
x=d*(n-1)+a;
d=3;
while(x<20)
{
n=n+1;
printf("T(%d)=%d",n,x);
if(x%3==0) q=q+n,p=p+1,printf("33的倍数有%d:%d\n",p,q);
}
while是用什么做条件好........
|