每個數後面都有一個空格,並且除第一組外其他組後都有一個空行!!
[csharp]
#include"stdio.h"
#include"math.h"
#include"string.h"
int prime[65537];
void fun()
{
int i,j,flag;
memset(prime,0,sizeof(prime));
for(i=2;i<65537;i++)
{
flag=1;
for(j=2;j<=i/2;j++)
if(i%j==0)
{
flag=0;break;
}
if(flag)
prime[i]=1;
}
}
int main()
{
int cou[65539];
int i,j,cas,count;
int n,nn;
fun();
cas=0;
while(scanf("%d",&n)!=EOF,n>0)
{
if(cas!=0)
printf("\n");
count=0;
nn=n;
cas++;
printf("Case %d.\n",cas);
memset(cou,0,sizeof(cou));
for(i=2;i<=n;i++)
{
while(prime[i]==1)
{
if(nn%i!=0) break;
else
{
cou[i]++;
nn=nn/i;
}
}
}
for(j=2;j<=n;j++)
{
if(cou[j])
{
printf("%d %d ",j,cou[j]);
continue;
}
}
printf("\n");
}
return 0;
}