#include<stdio.h>
struct num
{
int m;
struct num *next;
}number;
struct num *calculation(int n)
{
int a[n]= {0},i = 0,sum = 0, j = n-1;
struct num *p,*hd,*pf,*pd;
for(i=0;i<n;i++)
{
a[i] = 1;
}
p = (int *)malloc(sizeof(struct num));
hd = p;
while(a[n-1]!=n)
{
sum = 0;
for(i=0;i<n;i++)
{
printf("%d-",a[i]);
sum = sum+a[i];
}
printf("
%d\n",sum);
p->m = sum;
pd = p;
pf = (int *)malloc(sizeof(struct num));
p->next = pf;
p = pf;
for(i=1;i<n;i++)
{
if((a[n-i]>a[n-i-1])&&(a[n-i]!=n-i+1))
j=n-i-1;
}
a[j]++;
}
pd->next = NULL;
return hd;
}
int main()
{
int n = 0,i = 0,j = 1;
struct num *p;
scanf("%d",n);
p = calculation(n);
while(p!=NULL)
{
j = 1;
for(i=2;i<=p->m/2;i++)
if(p->m%i==0)
j=0;
if(j)
printf("%d
",p->m);
p = p->next;
}
}
我没有按XP下的编译器,也没按samba,要是在虚拟机的Linux里编译,还要把代码在写一遍,
交给你了,调试一下,修改一下,改不了的地方,或看不懂的地方在问我