STL之LIST使用
来源:互联网 发布:淘宝推广八戒晨昊网络 编辑:程序博客网 时间:2024/05/17 10:55
// List.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdlib.h"
#define NULL 0
#define TYPE struct stu
#define LEN sizeof(struct stu)
struct stu{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;++i)
{
pb=(TYPE *)malloc(LEN);
printf("input Number and Age \n");
scanf("%d\n%d",&pb->num,&pb->age);
//printf("input Number and Age \n");
if(i==0)
{
pf=head=pb;
}
else
{
pf->next=pb;
}
pb->next = NULL;
pf=pb;
if(i==4)
{
for(int n=0;n<=i;n++)
{
if(n==4)
{
pb=(TYPE *)malloc(LEN);
printf("插入链表");
scanf("%d\n%d\n",&pb->num,&pb->age);
pf=head->next;
pb->next=pf;
head = pb;
}
//pb=(TYPE *)malloc(LEN);
printf("input\n");
if(n==0)
pb=head;
else
pb=pb->next;
printf("%d\n%d\n",pb->age,pb->num);
}
}
}
return(head);
}
int _tmain(int argc, _TCHAR* argv[])
{
creat(5);
return 0;
}
//
#include "stdafx.h"
#include "stdlib.h"
#define NULL 0
#define TYPE struct stu
#define LEN sizeof(struct stu)
struct stu{
int num;
int age;
struct stu *next;
};
TYPE *creat(int n)
{
struct stu *head,*pf,*pb;
int i;
for(i=0;i<n;++i)
{
pb=(TYPE *)malloc(LEN);
printf("input Number and Age \n");
scanf("%d\n%d",&pb->num,&pb->age);
//printf("input Number and Age \n");
if(i==0)
{
pf=head=pb;
}
else
{
pf->next=pb;
}
pb->next = NULL;
pf=pb;
if(i==4)
{
for(int n=0;n<=i;n++)
{
if(n==4)
{
pb=(TYPE *)malloc(LEN);
printf("插入链表");
scanf("%d\n%d\n",&pb->num,&pb->age);
pf=head->next;
pb->next=pf;
head = pb;
}
//pb=(TYPE *)malloc(LEN);
printf("input\n");
if(n==0)
pb=head;
else
pb=pb->next;
printf("%d\n%d\n",pb->age,pb->num);
}
}
}
return(head);
}
int _tmain(int argc, _TCHAR* argv[])
{
creat(5);
return 0;
}
0 0
- stl之list使用
- STL之LIST使用
- STL之LIST使用
- 使用STL之list实现链表逆置
- stl之二: list使用总结【转】
- STL之list基本使用实例
- STL学习之list
- STL之list模板
- STL之list学习
- STL之List
- STL容器之list
- STL容器之list
- STL之count、list
- sgi stl 之list
- STL之list基础
- STL之list
- C++ STL之list
- stl库之list
- OpenStack之二
- VS2010 无法显示中文
- 项目收获-手动写个线程池。。
- 邮槽--进程间通信
- C++ scanf 函数与EOF 浅析
- STL之LIST使用
- 求连续子数组最大和问题的两种解法_PHP实现
- WebStorage概述
- 标准C++读写文件
- Java--内存分配全面浅析
- va_list va_start cfindfile遍历文件
- 关于心理的二十五种倾向(查理·芒格)-5
- Redis安装教程
- vector 类型输出的一个问题