怎么样改才能使输出前两个数


#include "stdio.h"

#include <malloc.h>

struct weapon{

int price;

int atk;

struct weapon * next;

};//缺;

struct weapon * create()

{

int a=0;

struct weapon *p1,*p2,*head;

p1=p2=(struct weapon *)malloc(sizeof(struct weapon));

scanf("%d%d",&p1->price,&p2->atk);

head=NULL;

while(p1->price!=0)

{

a++;

if(a==1)

head=p1;

else 

p2->next=p1;

   p2=p1;

p1=(struct weapon *)malloc(sizeof(struct weapon));

scanf("%d%d",&p1->price,&p2->atk);

}

p2->next=NULL;

return (head);

}

void main()

{

    struct weapon * p;

    p=create();

    printf("%d,%d",p->price,p->atk);//名打错

}


溯源1
浏览 1499回答 2
2回答

DOUBLE_l

不清楚你什么意思。
打开App,查看更多内容
随时随地看视频慕课网APP