1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 #include <string> 5 #include <cmath> 6 #include <algorithm> 7 #include <malloc.h> 8 using namespace std; 9 const int N = 1000; 10 11 struct weapon{ 12 int price; 13 int atk; 14 struct weapon * next; 15 }; 16 17 struct weapon *create(){ 18 struct weapon * head; 19 struct weapon * p1, *p2; 20 int n=0; 21 p1=p2=(struct weapon*)malloc(sizeof(struct weapon)); 22 scanf("%d %d",&p1->price,&p1->atk); 23 head=NULL; 24 while(p1->price!=0){ 25 n++; 26 if(n==1) head=p1; 27 else p2->next=p1; 28 p2=p1; 29 p1=(struct weapon*)malloc(sizeof(struct weapon)); 30 scanf("%d %d",&p1->price,&p1->atk); 31 } 32 p2->next=NULL; 33 return (head); 34 } 35 36 int main() 37 { 38 struct weapon *p; 39 p=create(); 40 printf("%d %d",p->price,p->atk); 41 return 0; 42 }