#include
void main()
{
int n,bmp;
int a[30],i,j,k,t=1;
int num=0,num2=0,num3=0,num5=0,num7=0;
for (;;i++)
{
num=0;num2=0;num3=0;num5=0;num7=0; //Òò×ÓÇåÁã
begin:
scanf("%d",&n);
if ( n>1000000000 || n<=0 ) //´íÎóÊäÈëÅжÏ
{
printf("ERROR!ÖØÐÂÊäÈë!\n");
goto begin;
}
else if (n>0&&n<10) //һλÊýÅжÏ
{
printf("QµÄÊýֵΪ1%d!\n\n",n);
goto exit;
}
/*Òò×Ó²¶»ñ²¿·Ö*/
else if (n>=10) //ÕýÈ·ÊäÈëÅжÏ
{
//²¶»ñÒò×Ó
for (;;i++)
{
if ( n%2==0 && n!=2 )
{num2+=1;n/=2;
}
else if ( n%3==0 && n!=3 )
{num3+=1;n/=3;
}
else if ( n%5==0 && n!=5 )
{num5+=1;n/=5;
}
else if ( n%7==0 && n!=7 )
{num7+=1;n/=7;
}
if (n==2) //²¶»ñÖÕÖµ
{num2+=1;break;
}
if (n==3)
{num3+=1;break;
}
if (n==5)
{num5+=1;break;
}
if (n==7)
{num7+=1;break;
}
if ( n%2!=0 &&
n%3!=0 &&
n%5!=0 &&
n%7!=0 ) //Í˳öÅжÏ
{printf("ÎÞ½â!");goto exit;
}
}
}
// printf("2=%d 3=%d 5=%d 7=%d\n",num2,num3,num5,num7); ÑéÖ¤Òò×Ó²¶»ñÊÇ·ñ³ÉÁ¢!
/*Òò×ÓдÈ벿·Ö*/
for (i=0;i<30;i++) a[i]=1; //Êý×é³õʼ»¯
for (i=0;i
num+=num2;
for (i=num;i
num+=num3;
for (i=num;i
num+=num5;
for (i=num;i
// for (i=0;i<30;i++) printf("%2d",a[i]); // ÑéÖ¤Òò×ÓÊÇ·ñÕýȷдÈë
// printf("\n\n");
//************************ÒÔÉÏ´úÂë¿éÔËÐе÷ÊÔÍê±Ï!************************//
/*Òò×Ӻϲ¢²¿·Ö*/
//Òò×Ӻϲ¢¿éµ÷ÊÔÖÐ......
for (k=0;k<30;k++)
{
if ((a[k]*a[k+1])<10)
{
a[k+1]=a[k+1]*a[k];
a[k]=1;
t++;
}
if ( (a[k]*a[k+1])>=10 && t>0 )
{
for (i=0;i<29;i++)
{
for (j=0;j<29-i;j++)
{
if (a[j]>a[j+1])
{
bmp=a[j];
a[j]=a[j+1];
a[j+1]=bmp;
}
else
continue;
}
}
}
}
// for (i=0;i<30;i++) printf("%2d",a[i]);
// printf("\n\n");
//ÁоÙÒò×Ó²¢Éú³ÉÊýÖµQ
printf("QµÄÊýֵΪ");
for (i=0;i<30;i++)
{
if (a[i]==1) continue;
printf("%d",a[i]);
}
printf("!\n\n");
}
exit:
printf("\n");
}
貌似论坛的代码不支持中文~ 重新发一次~
to be or not to be