C++——小案例:学生通讯录

利用C++来实现一个通讯录管理系统

系统中需要实现的功能如下:

- 添加联系人:向通讯录中添加新人,信息包括(姓名、性别、年龄、联系电话、家庭住址)最多记录1000人
- 显示联系人:显示通讯录中所有联系人信息
- 删除联系人:按照姓名进行删除指定联系人
- 查找联系人:按照姓名查看指定联系人信息
- 修改联系人:按照姓名重新修改指定联系人
- 清空联系人:清空通讯录中所有信息
- 退出通讯录:退出当前使用的通讯录

#include 
#include 
#include 
#include 
#include 

using namespace std;

typedef enum Gender{
    male,female
} gender;

typedef struct Student {
    string name;
    int age;
    Gender gender;
    string phone_number;
} student;

#define NUM 100 //student arry total number
typedef struct Addressbook{
    student student_arr[NUM];
    int size; // how many students present in addressbook

} addressbook;


void add_student(addressbook * abs){
    string name;
    int age;
    gender sex;
    string phone_number;

    if (abs->size==NUM) {
        cout << "addressbook is full "<> name;
    abs->student_arr[abs->size].name=name;
    //age
    cout << "age" << endl;
    cin >> age;
    abs->student_arr[abs->size].age=age;
    //gender
    cout <<"0-male,1-female"<student_arr[abs->size].gender=sex;
    }else {
        cout <<"0-male,1-female"<student_arr[abs->size].gender=sex;
                break;
        }
    }
    }
    //phone_number
    cout <<"phone_number"<> phone_number;
    abs->student_arr[abs->size].phone_number=phone_number;

    abs->size++;
    cout <<"add successful ! "<size==0) {
        cout <<"no any student"<size; i++) {
            cout <<"name:"<< abs->student_arr[i].name <student_arr[i].age <student_arr[i].gender <student_arr[i].phone_number <size; i++) {
        if (abs->student_arr[i].name==name) {
            return i;
        }
    }
    return -1;

}
void find_student(){
    
}
void modify_student(){
    
}
void delete_student(){
    
}
void delete_all_students(){
    
}

void showmenu(){

    cout << "***************************" <> select;
        switch (select) {
        case 1 :
            add_student(&ads);
            break;
        case 2 :
            show_student(&ads);
            break;
        case 3 :
            find_student();
            break;
        case 4 :
            modify_student();
            break;
        case 5 :
            delete_student();
            break;
        case 6 :
            delete_all_students();
            break;
        case 7 :
            goto EXIT;
        default:
            break;
        }
    
    }
    EXIT:
        cout << "thanks for using!" << endl;
    return 0;
}

你可能感兴趣的:(c++,算法,开发语言)