呵呵我做出来了,还做了张图
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
void main(void)
{
int sum,r1=1,r2=0,r3=0;
int i,j,k;
int n;
int g=VGA,mode=VGAHI;
int x,y;
int x0,y0;
int *p;
clrscr();
printf("input the n:");
scanf("%d",&n);
p=(int *)malloc(n*sizeof(int));
if (p==NULL)
{
printf("\nwrong!\n");
exit(0);
}
printf("input the 3p:");
scanf("%f%f%f",&p1,&p2,&p3);
initgraph(&g,&mode,"");
setbkcolor(WHITE);
setcolor(BLUE);
line(150,380+5,150,50);
line(150,380,500,380);
moveto(150,50);
linerel(-3,6);
moveto(150,50);
linerel(3,6);
moveto(500,380);
linerel(-6,-3);
moveto(500,380);
linerel(-6,3);
for (j=0;j<=300;j+=25)
{
line(145,380-j,150,380-j);
}
for (k=0;k<=300;k+=25)
{
line(k+150,380,k+150,377);
}
for (i=2;i<=n;i++)
{
r3=r3+;
r2=r1;
r1=r3;
sum=r1+r2+r3;
x0=i*10;
y0=sum/2;
x=x0+150;
y=480-1*y0-100;
*(p+(i-2)*2)=x;
*(p+(i-2)*2+1)=y;
}
drawpoly(n,p);
getchar();
getchar();
getchar();
closegraph();
free(p);
}