为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

溯源1 2017-01-09 11:59:30
#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);//名打错}
查看完整描述

2 回答

?
DOUBLE_l

TA贡献45条经验 获得超12个赞

不清楚你什么意思。
查看完整回答
反对 回复 2017-01-09
  • 溯源1
    溯源1
    我输入1 1 2 2 3 3 0 0,它打印1 2,为什么不是打印头两个数 1 1
  • 2 回答
  • 0 关注
  • 1438 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信