#include
int main()
{
int n,i,max=1;
scanf("%d",&n);
for(i=1;i<=n;i++)
if(i%3==0)
max=max*i;
for(i=1;i<=n;i++)
if(i%3==0)
printf("%d*",i);
printf("\b=%d\n",max);
return 0;
}
#include
void main()
{
int i,j,N;
scanf("%d",&N);
j=1;
for(i=3;i<=N;i++)
{
if(i%3==0)
{
if(j==1)
printf("%d",i);
else
printf("*%d",i);
j*=i;
}
}
printf("=%d",j);
}
经过测试的
#include
void main()
{
int n,arr[20]={-1},i;
printf("please input the n:\n");
scanf("%d",&n);
while(n>20){
printf("n should be less than 20,input again:\n");
scanf("%d",&n);
}
int idx=0,sum=1;
for(i=1;i<=n;i++){
if(i%3==0)
arr[idx++]=i;
}
for(i=0;i printf("%d*",arr[i]); sum*=arr[i]; } sum*=arr[idx-1]; printf("%d=%d\n",arr[idx-1],sum); //最后一个能被3整除的数都是 只有数字 单独打印 }
#include
int main() {
int n, s = 1, i;
scanf("%d",&n);
for (i = 3; i <= n; i += 3)
s *= i;
printf("%d\n",s);
return 0;
}