⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 单链表1.c

📁 这里面包含了大量的数据结构的常用算法,大家可一看看有不有对自己有用的东西
💻 C
字号:
#include<stdlib.h>
#include<stdio.h>
struct roommate
{
char name;
long num;
int age;
char birthplace;
struct roommate *next;
};
struct roommate *head,*cthis,*cnew;

void ins_record(void)
{
int i,j=0;
char numstr,b;
cthis=head;
printf("\nInput a num :");
scanf("%d",&i);
while(j<i-2)
  {
  cthis=(struct roommate*)malloc(sizeof (struct roommate));
  cthis=cthis->next;
  ++j;

  }
  if(j>i-1)
  return;
  cnew=(struct roommate*)malloc(sizeof (struct roommate));
 
  printf("\nplease input the information:");
  printf("\nenter name:");
  scanf("%s", &cnew->name);
 
  printf("\nenter number:");
  scanf("%ld",&cnew->num);
  printf("\nenter age:");
  scanf("%d",&cnew->age);
  printf("\nenter birthplace:");
  scanf("%s",&cnew->birthplace);
  cnew->next=cthis;

}
main()
{
ins_record();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -