学生通讯录 管理系统 C++代码

更新时间:2023-07-27 08:30:16 阅读: 评论:0

/*
1-----新建学生通讯录              2-----向学生通讯录插入学生信息
3-----在通讯录删除学生信息        4-----从文件中读取通讯录信息
5-----向文件写入学生通讯录信息    6-----在通讯录中查询学生信息
7-----在屏幕中输出全部学生信息    8-----退出
请选择操作:
*/
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<string.h>
using namespace std;
class Student;
ostream& operator<<(ostream & os, Student & obj);
istream& operator>>(istream & is, Student & obj);
class Student
{
public:
    string Name;
    string Number;
    string Birthday;
    string Sex;
    string PhoneNumber;
    string Adress;
public:
    Student * next;
public:
    Student();
    Student(int){next=NULL;};
    void show();军号声
    friend ostream& operator<<(ostream & os, Student & obj);
    friend istream& operator>>(istream & is, Student & obj);
    //~Student();
};
Student::Student()
{
    cout<<"\n<Name ? ";
    cin>>Name;
    cout<<"<Number ? ";
    cin>>Number;
    cout<<"<Birthday ? ";
    cin>>Birthday;
    cout<<"<Sex ? ";
    cin>>Sex;
    cout<<"<PhoneNumber ? ";
    cin>>PhoneNumber;
    cout<<"<Adress ? ";
    cin>>Adress;
    next=NULL;
}
void Student::show()
高压锅{
    /*
    cout<<"--------------------------------------------"<<endl;
    cout<<">Name: "<<Name<<endl;
    cout<<">Number: "<<Number<<endl;
    cout<<">Birthday: "<<Birthday<<endl;
    cout<<">Sex: "<<Sex<<endl;
    cout<<">PhoneNumber: "<<PhoneNumber<<endl;
    cout<<">Adress: "<<Adress<<endl;
    cout<<"--------------------------------------------"<<endl;
    cout<<endl;
    */
    cout<<std::left<<tw(13)<<"Name"<<tw(13)<<"Number"<<tw(10)<<"Birthday"<<tw(6)<<"Sex"<<tw(13)<<"PhoneNumber"<<tw(21)<<"Adress"<<endl;
    cout<<"------------------------------------------------------------------------------\n";
    cout<<*this<<endl;
}
ostream& operator<<(ostream & os, Student & obj)
{
    /*os<<"--------------------------------------------"<<endl;
    os<<">Name: "<<obj.Name<<endl;
    os<<">Number: "<<obj.Number<<endl;
    os<<">Birthday: "<<obj.Birthday<<endl;
变化率计算公式    os<<">Sex: "<<obj.Sex<<endl;
    os<<">PhoneNumber: "<<obj.PhoneNumber<<endl;
    os<<">Adress: "<<obj.Adress<<endl;
    os<<"--------------------------------------------"<<endl;
    os<<endl;
    return os;*/
    os<<std::left<<tw(13)<<obj.Name<<tw(13)<<obj.Number<<tw(10)<<obj.Birthday<<tw(6)<<obj.Sex<<tw(13)<<obj.PhoneNumber<<tw(20)<<obj.Adress<<endl;
    os<<"-----------------------------------------------------------------------------"<<endl;
    return os;
}
istream& operator>>(istream & is, Student & obj)
{
    /*
    char temp[200];
    is>>temp;
    is>>obj.Name;
    is>>temp;
    is>>obj.Number;
    is>>temp;
    is>>obj.Birthday;
    is>>temp;
    is>>obj.Sex;
    is>>temp;
    is>>obj.PhoneNumber;
    is>>temp;
    is>>obj.Adress;
    is>>temp;
    return is;
    */
    char temp[200];
    is>>obj.Name>>obj.Number>>obj.Birthday>>obj.Sex>>obj.PhoneNumber>>obj.Adress;
    is>>temp;
    return is;
}
class InfList
{
public:
    Student * head, * tag;
    int size;
public:
    InfList(){head=tag=NULL; size=0;}
    ~InfList(){delete[] head;}
    bool BulidFromFile();
    void Inrt();
    void Delete(string name);
徐组词语
    void Find(string name);
    void PrintAll();
阿弥陀丸    void WriteToFile();
    void GetFromFile();
    static int flag;
   
};
卡片怎么做int InfList::flag = 0;
void InfList::Inrt()
{
    Student * p=new Student;
    if(head==NULL)
        head=tag=p;
    el
    {
        tag->next=p;
        tag=p;
    }
    cout<<"插入成功"<<endl;
}
void InfList::Find(string name)
{
    if(head==NULL)
        cout<<"通讯录为空!"<<endl;
    el
    {
        Student * p;
        for(p = head; p; p=p->next)
        {
            if(p->Name==name)
            {
                p->show();
                break;
            }
        }
怀孕饮食        if(p==NULL)
            cout<<"不存在此人!"<<endl;
       
    }
}
void InfList::Delete(string name)
{
    if(head==NULL)
        cout<<"通讯录为空!"<<endl;
    el
    {
        Student * p, * q;
        for(p=head; p&&(p->Name!=name); q=p,p=p->next);
诸葛亮的成语        if(p==head)

本文发布于:2023-07-27 08:30:16,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1119703.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:学生   信息   通讯录   选择
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图