~Oo爆米花oO~ • 4个月前
using namespace std; struct stu {
char num[25], name[45], sex, scr[45];
int age;
char addr[45];
bool scan()
{
scanf("%s", num);
if(strcmp(num, "end") == 0) return true;
scanf("%s %c", name, &sex);
scanf("%d %s %s", &age, scr, addr);
return false;
}
void print()
{
printf("%s %s %c ", num, name, sex);
printf("%d %s %s\n", age, scr, addr);
}
}; struct node{
stu data;
node *pre, *next;
}head, tail, *p; int main(){
head = new node;
head -> next = NULL;
head -> pre = NULL;
tail = head;
while(1){
p = new node;
if(p -> data.scan()) break;
p -> pre = tail;
tail -> next = p;
p -> next = NULL; tail = p;
}
p = tail;
while(p != head){
p -> data.print();
p = p -> pre;
}
return 0;
}
评论:
请先登录,才能进行评论