鱼C论坛

 找回密码
 立即注册
查看: 3618|回复: 0

VC6中窗口一闪而过

[复制链接]
发表于 2012-10-25 20:57:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. # include <stdio.h>
  2. # include <malloc.h>
  3. # include <stdlib.h>

  4. typedef struct Node
  5. {
  6.         int date;
  7.         struct Node * pNext;
  8. }*PNODE, NODE;

  9. void Show_list(PNODE pHead)
  10. {
  11.         PNODE p = pHead->pNext;
  12.         while (NULL != p)
  13.         {
  14.                 printf("%d", p->date);
  15.                 p = p->pNext;
  16.         }
  17. }

  18. PNODE Create_list(void)
  19. {
  20.         int len;
  21.         int val;
  22.         PNODE pHead = (PNODE)malloc(sizeof(NODE));
  23.         if (NULL == pHead)
  24.         {
  25.                 printf("分配失败!");
  26.                 exit(-1);
  27.         }

  28.         PNODE pTail = pHead;
  29.        
  30.         printf("Please input the length to the LIST: length = ");
  31.         scanf ("%d", &len);
  32.        
  33.         for (int i=0; i<len; i++)
  34.         {
  35.                 printf("请输入第%d个节点的数值", i+1);
  36.                 scanf ("%d", &val);
  37.                
  38.                 PNODE pNew = (PNODE)malloc(sizeof(NODE));

  39.                 pTail->pNext = pNew;
  40.                 pNew->date = val;
  41.                 pNew->pNext = NULL;       
  42.                 pTail = pNew;
  43.         }
  44.        
  45.         return pHead;       
  46. }

  47. int main (void)
  48. {
  49.         PNODE pHead = (PNODE)malloc(sizeof(NODE));
  50.        
  51.         pHead = Create_list();
  52.         Show_list(pHead);
  53.        
  54.        
  55.         return 0;
  56. }
复制代码
这个是小弟在看数据结构时候写的链表,运行是输入链表长度为3时候Please input the length to the LIST: length = 3请输入第1个节点的数值1
请输入第2个节点的数值2
请输入第3个节点的数值3
123Press any key to continue
但是当length = 5时候却是一闪而过,求解??




小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-15 22:26

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表