zoukankan      html  css  js  c++  java
  • 数据结构:统计学生信息(c++动态链表完成)

    6379:统计学生信息(使用动态链表完成)

    描述

    利用动态链表记录从标准输入输入的学生信息(学号、姓名、性别、年龄、得分、地址)其中,学号长度不超过20, 姓名长度不超过40, 性别长度为1, 地址长度不超过40

    输入

    包括若干行,每一行都是一个学生的信息,如:
    00630018 zhouyan m 20 10.0 28#460
    输入的最后以"end"结束

    输出

    将输入的内容倒序输出
    每行一条记录,按照 “学号 姓名 性别 年龄 得分 地址” 的格式输出

    样例输入

    00630018 zhouyan m 20 10 28#4600
    0063001 zhouyn f 21 100 28#460000
    0063008 zhoyan f 20 1000 28#460000
    0063018 zhouan m 21 10000 28#4600000
    00613018 zhuyan m 20 100 28#4600
    00160018 zouyan f 21 100 28#4600
    01030018 houyan m 20 10 28#4600
    0630018 zuyan m 21 100 28#4600
    10630018 zouan m 20 10 28#46000
    end
    

    样例输出

    10630018 zouan m 20 10 28#46000
    0630018 zuyan m 21 100 28#4600
    01030018 houyan m 20 10 28#4600
    00160018 zouyan f 21 100 28#4600
    00613018 zhuyan m 20 100 28#4600
    0063018 zhouan m 21 10000 28#4600000
    0063008 zhoyan f 20 1000 28#460000
    0063001 zhouyn f 21 100 28#460000
    00630018 zhouyan m 20 10 28#4600
    

    话不多说上代码!!!

    #include<bits/stdc++.h>
      using namespace std;
      struct node
      {
          string st;
          struct node *pre;
      };
      
      int main()
    {
         int i;
         string s;
         struct node *head,*t;
         head=new struct node;
     
         getline(cin,s); 
         head->st=s; 
         head->pre=NULL;
         t=head;
     
         while (true)
         {
             getline(cin,s);
             if (s=="end"){ break; }
             head=new struct node;
             head->st=s;
             head->pre=t;
             t=head; 
         }
     
         head=new struct node;
         head->pre=t;
     
         while (head->pre!=NULL)
         {
             head=head->pre;
             cout<<head->st<<endl;    
         }
         return 0;
    }

    留个赞再走哦~

  • 相关阅读:
    ajax上传图片的本质
    牛逼的bootcss之buttons
    PHP实现登录,注册,密码修改
    thinkphp中的session()方法
    微信企业号支付个人php实现
    js判断是否是用微信浏览器打开
    助店宝微信商城登录流程图
    微信网页授权
    微信公众平台模板消息发送接口文档
    微信JS-SDK实现自定义分享功能,分享给朋友,分享到朋友圈
  • 原文地址:https://www.cnblogs.com/Kuller-Yan/p/12914126.html
Copyright © 2011-2022 走看看