输出1000以内能被3整除且至少有一位是3得数,每行输出4个
大家看看这个程序哪里有错误,还有没有更简洁效率更高的程序?#include<stdio.h>
void main()
{
int i,j,k;
for(i=0;i<=9;i++)
{
if((i+5)%3==0)
{
printf("%3d %3d",i*10+5,50+i);
k+=2;
if(k%4==0)
printf("\n");
}
for(j=0;j<=9;j++)
{
if((i+j+5)%3==0)
{
if(i!=j)
{
if((i!=5)&&(j!=5))
{
printf("%3d %3d ",500+10*i+j,500+10*j+i);
k+=2;
if(k%4==0)
printf("\n");
else
{
printf("%3d %3d ",100*i+10*j+5,100*i+50+j);
k+=2;
}
if(k%4==0)
printf("\n");
else
{
printf("%3d %3d ",100*j+10*i+5,100*j+50+i);
k+=2;
}
if(k%4==0)
printf("\n");
}
if(i==5)
{
if(k%4==1||k%4==0)
{
printf("%3d %3d %3d ",550+i,505+10*i,100*i+55);
k+=3;
if(k%4==0)
printf("\n");
}
else
{
if(k%4==2)
{
printf("%3d %3d \n%3d ",550+i,505+10*i,100*i+55);
k+=3;
}
else
{
if(k%4==3)
{
printf("%3d \n%3d %3d ",550+i,505+10*i,100*i+55);
k+=3;
}
}
}
if(j==5)
{}
}
if(i==j&&i!=5)
{
if(k%4==1||k%4==0)
{
printf("%3d %3d %3d ",500+10*i+i,100*i+50+i,100*i+10*i+5);
k+=3;
if(k%4==0)
printf("\n");
}
else
{
if(k%4==2)
{
printf("%3d %3d \n%3d ",500+10*i+i,100*i+50+i,100*i+10*i+5);
k+=3;
}
else
{
printf("%3d \n%3d %3d ",500+10*i+i,100*i+50+i,100*i+10*i+5);
k+=3;
}
}
}
if(i==j&&i==5)
printf("%3d ",555);
}
}
}
}