zoukankan      html  css  js  c++  java
  • 链表学习

    细细理解

     1 #include <stdio.h>
     2 #include <iostream>
     3 #include <string>
     4 #include <string.h>
     5 #include <math.h>
     6 #include <algorithm>
     7 #include <stdlib.h>
     8 using namespace std;
     9 struct film{
    10     char title[45];
    11     int rating;
    12     struct film * next;
    13 };
    14 int main()
    15 {
    16     struct film * head = NULL;
    17     struct film * prev, * current;
    18     char input[45];
    19     
    20     puts("enter first movie title: ");
    21     while(gets(input) != NULL && input[0] != ''){
    22         current = (struct film *)malloc(sizeof(struct film));
    23         if(head == NULL)
    24            head = current;
    25         else
    26            prev->next = current;
    27         current->next = NULL;    
    28         strcpy(current->title,input);
    29         puts("rating : ");
    30         scanf("%d",&current->rating);
    31         while(getchar() != '
    ')
    32            continue;
    33         puts("enter next movie title : ");
    34         prev = current;
    35     }
    36     if(head == NULL)
    37        printf("NO data entered.");
    38     else
    39        printf("Here is the movie list: 
    ");
    40     current = head;
    41     while (current != NULL)
    42     {
    43         printf("Movie: %s Rsting: %d
    ",current->title,current->rating);
    44         current = current->next;
    45     }
    46     current = head;
    47     while (current != NULL)
    48     {
    49         free(current);
    50         current = current->next;
    51     }
    52     printf("Bye!
    ");
    53     return 0;
    54 }
  • 相关阅读:
    hdu 1018
    hdu 1005
    hdu 1222
    hdu 1297
    hdu 1568
    WCF入门, 到创建一个简单的WCF应用程序
    BarTender 通过ZPL命令操作打印机打印条码, 操作RFID标签
    WCF入门的了解准备工作
    C# Bartender模板打印 条码,二维码, 文字, 及操作RFID标签等。
    Qt configure脚本说明
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/4664249.html
Copyright © 2011-2022 走看看