#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define LEN 6
//数列长度
#define COUNT 160
//范围
int ary[LEN], cnt = 0;
int *a = NULL;
int judge(int m)
{
int i;
for(i=2; i<=sqrt(m);i++)
if(m%i==0)
break;
if(i>sqrt(m))
return 1;
else
return 0;
}
void GetNext(int s, int n, int d)
{
int i;
if (n == LEN)
{
for (i = 0; i < LEN; i ++)
{
printf("%d ", ary[i]);
}
printf("\n");
return;
}
for (i = s; i < cnt; i ++)
{
if (a[i]-ary[0] == n*d)
{
ary[n++] = a[i];
GetNext(i+1, n, d);
return;
}
}
}
void GetQueue(void)
{
int i, j, d;
for (i = 0; i < cnt; i ++)
{
for (j = i+1; j < cnt; j ++)
{
d = a[j] - a[i];
ary[0] = a[i];
ary[1] = a[j];
GetNext(j, 2, d);
}
}
}
int main(void)
{
int i;
memset(ary, 0, sizeof(ary));
for (i = 2; i < COUNT; i ++)
{
if (judge(i))
{
a = realloc(a,sizeof(int)*(++cnt));
a[cnt-1] = i;
}
}
for (i = 0 ; i < cnt; i ++)
{
printf("%d ", a[i]);
}
printf("\n");
GetQueue();
free(a);
}