1. 程式人生 > >資料結構課程設計-學生資訊管理系統

資料結構課程設計-學生資訊管理系統

/*        
 *          煙臺大學計算機與控制工程學院       
 *檔名稱:mian.cpp       
 *作    者:王旭       
 *完成日期:2015年12月25日       
 *版 本 號:v1.0     
 *       
 *問題描述:學生資訊管理系統 
 *            
 *輸入描述:無
 *程式輸出:無
 */  


main.cpp:

#include<stdio.h>
#include<iostream>
#include<malloc.h>
#include<string.h>
#include"student.h"
#include<stdlib.h>
#include<windows.h>
using namespace std;
int main()         //方便後面呼叫各種函式,多加了一層函式
{
    Welcome();
}

void Welcome()
{
	int num=1;
	Student *head;
	head=(Student *)malloc(sizeof(Student)); //chuan
	head->next=NULL;
	while(num!=7)
	{
	    system("cls");
        cout<<"              ***************歡迎使用學生資訊管理系統************"<<endl;
        cout<<"              ***************請輸入你要使用的業務程式碼************"<<endl;
        cout<<"              ***********  1 輸入  2 查詢  3 修改    ************"<<endl;
	    cout<<"              ***********      4 插入  5 刪除        ************"<<endl;
        cout<<"              ***********      6 儲存  7 退出        ************"<<endl;
        cin>>num;
	    switch(num)
	    {
            case 1:
                StuIn(head);  //輸入學生資訊
		        break;
	        case 2:
		        StuSelect(head); //查詢學生資訊
		        break;
	        case 3:
		        StuAlter(head);  //修改學生資訊
		        break;
	        case 4:
		        StuInsert(head); //插入學生資訊   (包括頭插、尾插)
		        break;
	        case 5:
		        StuDelect(head); //刪除學生資訊
		        break;
	        case 6:
                StuSave(head);   //儲存學生資訊
		        break;
            case 7:
                cout<<"歡迎下次使用^-^"<<endl;
                Sleep(1000);
                exit(0);
		        break;
	        default:
	            cout<<"輸入正確地業務序號(⊙o⊙)"<<endl;
		        break;
        }

    };
}






student.cpp
#include<stdio.h>
#include<windows.h>
#include<iostream>
#include<malloc.h>
#include<string.h>
#include"student.h"
using namespace std;

void StuInHand(Student *head);    //手動輸入,由輸入函式呼叫
void StuInFile(Student *head);    //檔案輸入,由輸入函式呼叫
void StuIn(Student *);            //輸入函式,由主函式呼叫
void Sleep();                     //程式等待一秒
void StuIn(Student *head)         //輸入函式,由主函式呼叫
{
	int num;
	system("cls");
	while(num!=3)
	{
    cout<<"              *******************請選擇輸入方式******************"<<endl;
    cout<<"              **    1   手動輸入     2 檔案輸入     3 退出     **"<<endl;
    cout<<"              ***************************************************"<<endl;
	cin>>num;
	    switch(num)
	    {
        case 1:
		     StuInHand(head);     //呼叫手動輸入函式
		     break;
	    case 2:
		     StuInFile(head);     //呼叫檔案輸入函式
             break;
        case 3:
             system("cls");       //清屏,重新回到Wlcome
		     Welcome;             //退出輸入介面,返回Welcome
		     break;
	    default:
		     cout<<"輸入正確的業務程式碼";
		     break;
	    }
	}
}

void StuSelect(Student *head)  //查詢函式,由主函式呼叫
{
    int s=1;                          //判斷函式是否繼續進行
	int num;
	while(s!=2)
	{
        cout<<"              ***********************查詢系統********************"<<endl;
        cout<<"              **********  1  遍歷  2 學號查詢    3 退出 *********"<<endl;
        cout<<"              ***************************************************"<<endl;
	    cin>>num;
        switch(num)
	    {
            case 1:
                StuFindErg(head);
		        break;
     	    case 2:
                StuFindNum(head);
		        break;
	        default:
		        s=2;
		        break;
	    }
	}
}


void StuAlter(Student *head)   //修改函式,由主函式呼叫
{
        int num;
	    cout<<"輸入想要查詢學生的學生號:";
        cin>>num;
		char Sub[10];
	    cout<<"輸入想要查詢科目:";
        cin>>Sub;
        Student *p=(Student *)malloc(sizeof(Student));
		p=head->next;
		int i=1;
		while(p!=NULL)
		{
			if(num==p->num&&!strcmp(Sub,p->subject))
			{
		       printf("輸入修改成績:\n");
			   scanf("%d",&p->score);
			   printf("修改成功\n");
			   Sleep(1000);
			   i++;
			}
			   p=p->next;

		}
}


void StuInsert(Student *head)  //插入函式,由主函式呼叫
{
    Student *point=(Student *)malloc(sizeof(Student));
    point=head->next;
    while(point->next!=NULL)
        point=point->next;
    int s=1;
    int num;
    while(s!=2)
    {
        cout<<"              **********************插入系統*********************"<<endl;
        cout<<"              ****      1  頭插       2 尾插       3 退出    ****"<<endl;
        cout<<"              ***************************************************"<<endl;
        cin>>num;
        Student *p=(Student *)malloc(sizeof(Student));
        switch(num)
        {
        case 1:
            StuIm(head,p);
            p->next=head->next;
            head->next=p;
            cout<<"插入成功!"<<endl;
            break;
        case 2:
            StuIm(head,p);
            point->next=p;
            p->next=NULL;
            cout<<"插入成功!"<<endl;
            break;
        default:
            s=2;
            break;
        }
    }
}

void StuDelect(Student *head)  //刪除函式,由主函式呼叫
{
    int num;
    char sub[10];
    cout<<"輸入想要刪除學生的學生號:";
    cin>>num;
    cout<<"輸入想要刪除科目:";
    cin>>sub;
    Student *p=(Student *)malloc(sizeof(Student));
    p->next=head->next;
    int i=1;
    while(p->next!=NULL)
    {
        if(num==p->next->num&&!strcmp(sub,p->next->subject))
        {
            StuOut(p->next);
            cout<<"是否刪除:1 是,2 否     ";
            cin>>i;
            if(num==head->next->num&&!strcmp(sub,head->next->subject))
            {
                head->next=head->next->next;
            }
            else
            {
			    p->next=p->next->next;
            }
            i=2;
            cout<<"刪除成功!"<<endl;
            break;
        }
        p=p->next;
    }
    if(i==1)
    cout<<"沒有該學生資訊"<<endl;
}


information.cpp
#include<stdio.h>
#include<windows.h>
#include<iostream>
#include<malloc.h>
#include<string.h>
#include"student.h"
using namespace std;
void StuInFile(Student *head)    //學生成績管理系統的檔案輸入函式,由輸入函式呼叫
{
    char filename[10];
    if(head->next!=NULL)
    {
        cout<<"系統已存在資訊。請轉入插入系統!"<<endl;
        return ;
    }
    FILE *fp;
    cout<<"請輸入檔案路徑(例如C:\text.txt)";
    cin>>filename;
    if((fp=fopen(filename,"r"))==NULL)
    {
        cout<<"不能開啟檔案,請檢查是否正確!"<<endl;
        return;
    }
    Student *point=(Student *)malloc(sizeof(Student));
    while(!feof(fp)) {
    Student *p=(Student *)malloc(sizeof(Student));
    p->next=NULL;
    fread(p,sizeof(Student),1,fp);
    if(head->next==NULL)
    {
        head->next=p;
        point=p;
    }
    else
    {
        point->next=p;
        point=p;
    }
};
    fclose(fp);
    cout<<"傳輸成功!"<<endl;
}

void StuSave(Student *head)    //儲存函式,由主函式呼叫
{
        FILE *fp;
		char filename[10];
		cout<<"請輸入儲存的檔名(例如:C:\text.txt):";
		cin>>filename;
		Student *p=(Student *)malloc(sizeof(Student));
		p=head->next;
		if((fp=fopen(filename,"w"))==NULL)
		 {
             cout<<"找不到該檔案!"<<endl;
             return;
         }
        cout<<"儲存成功!"<<endl;
        while(p!=NULL)
        {
             fwrite(p,sizeof(Student),1,fp);
		     p=p->next;
		 }
    fclose(fp);
}

In_Out.cpp
#include<stdio.h>
#include<iostream>
#include<malloc.h>
#include<string.h>
#include"student.h"
#include<stdlib.h>
using namespace std;
void StuOut(Student *p)           //輸出函式,將連結串列某個節點的資訊輸出
{
    cout<<"學生姓名:";
    cout<<p->name;
    cout<<"學生學號:";
    cout<<p->num;
    cout<<"考試科目:";
    cout<<p->subject;
    cout<<"科目成績";
    cout<<p->score<<endl;
}
int StuIm(Student *head,Student *p)
{
    Student *Opinion=(Student *)malloc(sizeof(Student));         //用來判斷輸入節點中學生號是否有重複
    Opinion=head->next;
    cout<<"學生姓名:";
    cin>>p->name;
    cout<<"學生學號:";
    cin>>p->num;
    cout<<"考試科目:";
    cin>>p->subject;
    if(Opinion!=NULL)
    {
        if(Opinion->num==p->num&&!strcmp(Opinion->subject,p->subject))
        {
            cout<<"該學生該科目已有成績";
            return 1;
        }
        Opinion=Opinion->next;
    }

    cout<<"學生成績:";
    cin>>p->score;

    return 0;
}


void StuInHand(Student *head)   //手動輸入函式,由輸入函式呼叫
{
      if(head->next==NULL)
	  {
	       Student *point=(Student *)malloc(sizeof(Student));
		   point->next=NULL;
		   int s=1;
		   while(s==1)
		   {
		       Student *p=(Student *)malloc(sizeof(Student));
			   p->next=NULL;
               StuIm(head,p);
			   if(head->next==NULL)
			   {
				   head->next=p;
			       point=p;
			   }
			   else
			   {
			       point->next=p;
				   point=p;
			   }
			   cout<<"是否繼續: 1 是,2 否    ";
			   cin>>s;
		   }
	  }
      else
	     {
	         cout<<"系統已存在資訊,請轉插入系統";
             system("cls");
	     }
}

Find.cpp
#include<stdio.h>
#include<windows.h>
#include<iostream>
#include<malloc.h>
#include<string.h>
#include"student.h"
using namespace std;
void StuFindErg(Student *head)    //遍歷函式,由查詢函式呼叫
{
        Student *p=(Student *)malloc(sizeof(Student));
		p=head->next;
		int i=1;
		while(p!=NULL)
		{
			   cout<<"第"<<i<<"位學生的資訊:"<<endl;
		       StuOut(p);
			   p=p->next;
			   i++;
		}
}
void StuFindNum(Student *head)   //查詢子函式,由查詢函式呼叫
{
	    int num;
	    cout<<"請輸入要查詢的學生的學號:";
        cin>>num;
        Student *p=(Student *)malloc(sizeof(Student));
		p=head->next;
		int i=1;
		while(p!=NULL)
		{
			if(num==p->num)
			{
		       StuOut(p);
			   i++;
			}
			   p=p->next;
		}
		 if(i==1)
		 cout<<"沒有該學生的資訊,請檢查輸入是否正確!";
}

student.h
#ifndef TEST_H
#define TEST_H
struct Student
{
   char name[10];     //姓名
   char subject[10];  //科目
   int num;           //學號
   int score;         //科目分數
   char email[10];     //郵箱
   Student *next;
};

void Welcome();                     //歡迎介面函式,由main函式呼叫
void StuSelect(Student *);          //查詢函式,由歡迎介面函式呼叫
void StuAlter(Student *);           //修改函式,由歡迎介面函式呼叫
void StuInsert(Student *);          //插入函式,由歡迎介面函式呼叫
void StuDelect(Student *);          //刪除函式,由歡迎介面函式呼叫
void StuSave(Student *);            //儲存函式,由歡迎介面函式呼叫
void StuFindErg(Student *head);     //遍歷函式,由查詢函式呼叫
void StuFindNum(Student *head);     //按學號查詢函式,由查詢函式呼叫
void StuOut(Student *p);            //輸出函式
int StuIm(Student *head,Student *p);//輸入函式
void StuIn(Student *);              //輸入函式,由歡迎介面函式呼叫

#endif
程式執行截圖

主介面


手動輸入成績


檔案輸入成績


檔案輸入成功


修改成功


刪除資訊


修改成功


刪除成功


退出介面


遍歷查詢


相關推薦

資料結構課程設計——學生資訊管理系統

/*Copyright (c)2017,煙臺大學計算機與控制工程學院 *All rights reservrd. *作者:趙楷文 *完成時間:2017年12月20日 *版本號:v1.0 *問題描述:設計一個管理學生資訊的

資料結構課程設計學生資訊管理系統

問題描述: /* * Copyright (c)2015,煙臺大學計算機與控制工程學院 * All rights reserved. * 檔名稱:aaaa.cbp * 作 者:張芸嘉 * 完成日期:2015年12月24日 * 版 本

資料結構課程設計-學生資訊管理系統

/* * 煙臺大學計算機與控制工程學院 *檔名稱:mian.cpp *作 者:王旭 *完成日期:2015年12月25日 *版 本 號:v1.0 *

資料結構課程設計——學生成績管理系統

} /************************************ * 功能描述:判斷學號是否重複 * 輸入引數:無 * 輸出引數:無 ************************************/ int num(LNode *a)//判斷學號是否重複 {   LNode *p=he

課程設計---學生資訊管理系統

/* *煙臺大學計算機與控制工程學院 /* *Copyright (c) 2015,煙臺大學計算機與控制工程學院 *All rights reserved. *檔名稱:lulu.cpp *作者:蘆亞茹 *完成日期:2015年12月31日 *版本號:v1.o *

課程設計————學生資訊管理系統(包含歷代思路和程式碼)

課程設計————學生管理系統(包含歷代思路和程式碼) 一.前言 學生資訊管理系統是我第一個獨立完成的比較長的程式碼,也算是花費了一些心血,這個系統是我一點點把它從幾百行的程式碼逐漸優化到上千行,功能從簡單到複雜。在這裡我把我的思路分享給大家,希望能給大家

課程設計-學生資訊管理系統

#include <iostream> #include <stdio.h> #include <stdlib.h> #include<windows.h> #include<string.h> #include<string> #inc

課程設計——學生資訊管理系統(順序表 連結串列)

實驗目的 : 1 、掌握線性表的定義; 2 、掌握線性表的基本操作,如建立、查詢、插入和刪除等。 實驗內容: 定義一個包含學生資訊(學號,姓名,成績)的的 順序表和連結串列,使其具有如下功能: (1) 根據指定學生個數,逐個輸入學生資訊; (2) 逐個顯示學生表

c語言課程設計學生成績管理系統

學生成績管理系統是比較適合初學者的。它涵蓋了c語言幾乎知識。對於學了c語言的人,把這個課程設計搞好(當然自己能設計出來是要有很好的基礎)。不管自己能不能夠完成,最重要的是能弄懂。參考其他資料,試著自己編寫是不錯的選擇。這個課程設計也是我參照資料,自己編寫的。自己適當地增加了

課程設計------學生考勤管理系統

#include <algorithm> #include <iomanip> #include <iostream> #include <vector> #include <stdexcept> #include <string> #i

MFC課程設計 --學生成績管理系統

MFC課程設計 ,C++課程設計 --學生成績管理系統 ps:因為課設完成的過程大家都不太一樣,以下的程式碼僅供學習一下在MFC下各個控制元件的用法,有問題歡迎留言討論。 實驗目的 使用MFC類庫編制應用程式:按鈕控制元件、靜態控制元件及編輯框的應用。 瞭解MF

資料結構課程設計學生資訊管理系統(煙大版)】

/* * Copyright (c) 2016, 煙臺大學計算機與控制工程學院 * All rights reserved. * 檔名稱:student.project * 作者:李瀟 * 完成日期:2016年12月28日 * 版本號:DEVC+

學生成績管理系統資料結構課程設計

學生成績管理問題  問題描述:建立兩個學生成績資訊表1、2,以檔案的形式分別進行儲存命名為1.txt和2.txt,然後實現將兩個檔案合併成一個新的檔案3.txt。 新檔案中有補考的學生查詢到,儲存到另一個檔案4.txt中。     基本要求:    

學生資訊管理系統資料庫課程設計

一.概述 學生資訊管理系統是學校管理的重要工具,是學校不可或缺的一部分。隨著在校人數的不斷增加,教務系統的數量也不斷的上漲。學校工作繁雜,資料眾多,人工管理資訊的難度也越來越大,顯然是不能滿足實際的需要,效率也是很低的。並且這種傳統的方式存在著眾多的弊端,如:保密性差.查詢不便.效率低,很難維

資料結構第一次作業(學生資訊管理系統-順序表&&連結串列)

實驗目的 : 1 、掌握線性表的定義; 2 、掌握線性表的基本操作,如建立、查詢、插入和刪除等。 實驗內容: 定義一個包含學生資訊(學號,姓名,成績)的的 順序表和連結串列,使其具有如下功能: (1) 根據指定學生個數,逐個輸入學生資訊; (2) 逐個顯示學生表中所有學生

學生資訊管理系統課程設計

/************************************************************************************************************************************** *

學生資訊管理系統(課程設計)

#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> using namespace std; struct studen

資料結構課程設計--圖書館管理系統原始碼

#include <iostream> #include <iomanip> #include <string.h> #include <string> #include <fstream>//輸入/輸出檔案流類

C語言課程設計學生資訊管理系統

#include"stdio.h" //標準的輸入輸出函式檔案頭部說明 #include"math.h" // 數學函式頭部說明 #include"string.h" #include"stdlib.h" //通過該函式頭部裡的

C++課程設計學生資訊管理系統

課程設計內容 1.)學生資訊的錄入:錄入新的學生的資訊; 2.)學生資訊的新增:新增新的學生的資訊; 3.) 學生資訊的刪除:刪除不需要的學生的資訊。 4.)學生資訊的查詢:查詢你需要的學生的資訊。 5.)學生資訊的修改:修改錯誤的學生的資訊。 6.)學生資訊的顯示:顯示所