📄 单链表1.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 + -