资源简介
C++数据结构线性表用链表实现学生信息系统
代码片段和文件信息
// Addresslist_2.cpp : Defines the entry point for the console application.
//
#include “stdafx.h“
#include “iostream“
#include “windows.h“
using namespace std;
struct data
{
char num[20];
char name[20];
char NO[20];
char email[30];
char address[50];
data *next;
};
const int length = 0;
class manage
{
public:
manage();
// manage(data a[] );
void creat();
void showlist();
int Getlength();
void adderuser();
void Windows();
void search();
void Delete();
void Deleteall();
void Modify();
private:
data *head;
int length;
};
manage ::manage()
{
head = new data;
head ->next = NULL;
length = 0;
}
void manage ::Modify()
{
data *p = head->next;
char s1[20];
char s5[50];
int k;
char s;
cout << “\t\t\t请输入学号:“;
cin >> s1;
while(p)
{
if(strcmp(p ->num s1) == 0)
{
//data *p1 = head;
cout << “\t\t\t************修改项**********\n“;
cout << “\t\t\t****************************\n“;
cout << “\t\t\t* 1:学号 2:姓名 *\n“;
cout << “\t\t\t* 3:联系方式 4:电子邮箱 *\n“;
cout << “\t\t\t* 5:家庭地址 0:退出 *\n“;
cout << “\t\t\t****************************\n“;
do
{
cout << “\n\t\t请输入选项:“;
cin >> k;
switch(k)
{
case 1:
{
char s2[20];
cout << “\n\t\t\t请重新输入学号:“;
cin >> s2;
strcpy(p -> num s2);
};
break;
case 2:
{
char s3[20];
cout << “\t\t\t请重新输入姓名:“;
cin >> s3;
strcpy(p ->name s3);
};
break;
case 3:
{
char s4[20];
cout << “\t\t\t请重新输入联系方式:“;
cin >> s4;
strcpy(p ->NO s4);
};
break;
case 4:
{
cout << “\t\t\t请重新输入电子邮箱“;
cin >> s5;
strcpy(p ->email s5);
};
break;
case 5:
{
cout << “\t\t\t请重新输入家庭地址“;
char s6[20];
cin >> s6;
strcpy(p ->address s6);
};
break;
case 0:
{
return;
};
break;
default:
{
cout << “\n\n“;
cout << “\t\t\t*********输入错误**********\n“;
// Modify();
return;
};
//break;
}
cout << “\n“;
cout << “\t\t\t*********修改成功**********\n“;
cout << “\t\t\t是否要继续修改(Y/N):“;
cin >> s;
}while(s == ‘Y‘);
//exit(1);
//cout << “\t\t\t********修改成功********\n“;
return;
}
else
p = p->next;
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE)FOREGROUND_INTENSITY|FOREGROUND_RED);
cout << “\n“;
cout << “\t\t\t对不起!不存在该生信息..........\n“;
}
void manage ::search()
{
data *p = head->next;
char s1[20];
char s2[20];
char s;
do
{
cout << “\n\t\t请输入需要查找学生的学号:“;
cin >>s1;
cout << “\t\t请输入需要查找学生的姓名:“;
cin >>s2;
while(p)
{
if(strcmp(p->num s1) == 0 && strcmp(p->name s2) == 0)
{
cout << “\t\t******************查找成功*********************\n“ << endl;
cout << “\t\t学号:“ << p->num << endl;
cout << “\t\t姓名:“ << p->name
评论
共有 条评论