九度代码1511

来源:互联网 发布:论文数据来源怎么标注 编辑:程序博客网 时间:2024/05/22 15:01
#include <stdio.h>#include <malloc.h>#include <string.h>typedef struct node{    int data;    struct node *next;}Node;void creatt(Node *head){    int k=0;    scanf("%d",&k);    while(1)    {        if(k == -1)        break;        Node *b=(Node *)malloc(sizeof(Node));        b->next=head->next;        head->next=b;        b->data=k;        scanf("%d",&k);    }}void printt(Node *head){ Node *p; p=head->next; while(p!=NULL) {  printf("%d\n",p->data);  p=p->next; }}int main(){    //freopen("D:\\in.txt","r",stdin);    Node * head=(Node *)malloc(sizeof(Node));    head->next=NULL;    creatt(head);    printt(head);}/**************************************************************    Problem: 1511    User: lhcc1115    Language: C    Result: Accepted    Time:90 ms    Memory:3948 kb****************************************************************/

0 0
原创粉丝点击