#include<stdio.h>
#include<stdlib.h>
struct student{
int num;
char name[20];
int card;
struct student *next;
};
typedef struct student studenttype;
typedef studenttype * pstudenttype;
pstudenttype top = NULL, rear = NULL;
int main(){
int n;
scanf("%d", &n);
pstudenttype p;
for(int i = 0; i < n; i++){
p = (pstudenttype)malloc(sizeof(studenttype));
if(p == NULL)
exit(1);
scanf("%d", &(p -> num));
scanf("%s", &(p -> name));
scanf("%d", &(p -> card));
if(top == NULL)
top = p;
if(rear == NULL)
rear = p;
else{
rear -> next = p;
p -> next = NULL;
rear = p;
}
}
FILE * fp;
fp = fopen("D:\\address.txt","a");
pstudenttype q = top;
for(int i = 0; i < n; i++){
char address[20];
fprintf(fp, "%4d", q -> num);
fprintf(fp, "%20s", q -> name);
fprintf(fp, "%15d", q -> card);
scanf("%s", address);
fprintf(fp, "%20s", address);
fprintf(fp, "\n");
q = q -> next;
}
fclose(fp);
return 0;
}
之后开始数据结构