- The fun function is written to realize the following functions: input any positive integer from the keyboard, find its non-even factors, and put them in the array pointed to by pp in ascending order, and return the number of these factors through the formal parameter n .
For example, input 27, the output is: the result is :3 9
#include<stdio.h>
int main()
{
void fun (int x,int *pp, int *n);
int x,a[100],*pp=a,n,i;
scanf("%d",&x);
fun(x,pp,&n);
printf("the result is :");
for(i=0;i<n;i++)
printf("%d ",pp[i]);
printf("\n");
return 0;
}
void fun (int x,int *pp, int *n)
{
int i,j=0,k=0;
for(i=1;i<x;i++)
if(x%i==0&&(i%2!=0))
{
pp[j++]=i;
k++;
}
*n=k;
}
(The example is wrong, no more complaints...)