以下便是了:
#include<stdio.h>
#include<ctype.h>
int join(int array[],int count);
int factor(int n);
int main(void)
{
int array[100];
char n;
int num,i,count;
while(getchar()!='\n')
{
for(count=0,i=0;i<100;)
{
n=getchar();
if(isdigit(n))
{
array[i]=(int)(n-'0');
count++;
i++;
}
if(n=='\n')
break;
}
num=join(array,count);
if(num==0)
printf("0\n");
else
printf("%d\n",factor(num));
}
return 0;
}
int join(int array[],int count)
{
int i,sum=0;
for(i=0;i<count;i++)
sum=sum*10+array[i];
return sum;
}
int factor(int n)
{
int j;
if(n==1)
return n;
for(j=n-1;j>1;j--)
{
if(n%j==0)
break;
}
if(j==1)
return n;
else
return j;
}
#include<stdio.h>
#include<ctype.h>
int join(int array[],int count);
int factor(int n);
int main(void)
{
int array[100];
char n;
int num,i,count;
while(getchar()!='\n')
{
for(count=0,i=0;i<100;)
{
n=getchar();
if(isdigit(n))
{
array[i]=(int)(n-'0');
count++;
i++;
}
if(n=='\n')
break;
}
num=join(array,count);
if(num==0)
printf("0\n");
else
printf("%d\n",factor(num));
}
return 0;
}
int join(int array[],int count)
{
int i,sum=0;
for(i=0;i<count;i++)
sum=sum*10+array[i];
return sum;
}
int factor(int n)
{
int j;
if(n==1)
return n;
for(j=n-1;j>1;j--)
{
if(n%j==0)
break;
}
if(j==1)
return n;
else
return j;
}