當前位置:首頁 » 課程大全 » 訂票系統數據結構課程設計

訂票系統數據結構課程設計

發布時間: 2020-11-29 23:19:29

『壹』 數據結構課程設計——飛機訂票系統

#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define m 4 //3架飛機
#define n 5 //每架飛機5張票

struct node
{
char name[21];
char id[21];
int seat,plane,date;
node *next,*pre;
};
struct wait
{
char name[21];
char id[21];
char phone[8];
int seat,plane,date,count;
wait *next,*pre;
};
struct piao
{
int seat[n+1];
};

void makenull();
void makenull_piao();
void makenull_information();
void list_menu();
void list_piao();
void makenull_wait();
void list_information();
void plane_information(node *head);
void book();
void add_information(node *head,int x,int y);
void add_wait(int x,int y);
void search_delete(int x);
void write_to_file();
void show_wait();
bool comp(node *x,node*y);

node *head1,*head2,*head3,*q;
wait *wait_head,*wait_end;
char c;
piao a[m];

void main()
{

makenull();
do
{ list_menu();
cout<<endl<<"choose an operation: ";
cin>>c;
if (c!='6')
switch(c)
{
case '0' : show_wait();break;
case '1' : {list_piao();book();}break;
case '2' : search_delete(1);break;
case '3' : list_piao();break;
case '4' : list_information();break;
case '5' : search_delete(0);break;
default : break;
}
}while(c!='6');
cout<<"Exit System ";
}
void makenull()
{
makenull_piao();
makenull_information();
makenull_wait();
}
void list_menu()
{ cout<<endl<<"";
cout<<endl<<" 菜單";
cout<<endl<<" ************************";
cout<<endl<<" * 0 . 查看排隊情況 *";
cout<<endl<<" * 1 . 訂票 *";
cout<<endl<<" * 2 . 退票 *";
cout<<endl<<" * 3 . 查看剩餘票 *";
cout<<endl<<" * 4 . 查看飛機信息 *";
cout<<endl<<" * 5 . 查看乘客信息 *";
cout<<endl<<" * 6 . 退出 *";
cout<<endl<<" ************************";
cout<<endl<<"";
}
void makenull_piao()
{
FILE *fp;
int i;
if((fp=fopen("piao.dat","r")) == NULL )
{
fp=fopen("piao.dat","w");
for (i=1;i<=m-1;i++)
fwrite(&a[i],sizeof(piao),1,fp);
fclose(fp);
fp=fopen("piao.dat","r");
}
for(i=1;i<=m-1;i++)
fread(&a[i],sizeof(piao),1,fp);
fclose(fp);
}
void makenull_information()
{
node *r;
FILE *fp;
int i,j,sum;

sum=a[1].seat[0]+a[2].seat[0]+a[3].seat[0];
fp=fopen("information.dat","r");
head1=new node;
head2=new node;
head3=new node;
head1->pre=NULL;
head1->next=NULL;
head2->pre=NULL;
head2->next=NULL;
head3->pre=NULL;
head3->next=NULL;
q=head1;
for(i=1;i<=sum;i++)
{
j=0;
r=new node;
fread(r,sizeof(node),1,fp);
q->next=r;
r->pre=q;
r->next=NULL;
q=q->next;
fclose(fp);
if(i==a[1].seat[0]+1) {
head2->next=q;
q->pre->next=NULL;
q->pre=head2;
}
if(i==a[1].seat[0]+a[2].seat[0]+1) {
head3->next=q;
q->pre->next=NULL;
q->pre=head3;
}
}
}

void makenull_wait()
{
wait *tempw;
FILE *fp;
tempw=new wait;
int i;
if((fp=fopen("wait.txt","r")) ==NULL )
{
fp=fopen("wait.txt","w");
fclose(fp);
}
wait_end=new wait;
wait_head=new wait;
wait_end->next=NULL;
wait_end->pre=NULL;
wait_head=wait_end;
wait_head->count=0;
fp=fopen("wait.txt","r");
fread(wait_head,sizeof(wait),1,fp);
for(i=1;i<=wait_head->count;i++)
{
fread(tempw,sizeof(wait),1,fp);
wait_end->next=tempw;
tempw->pre=wait_end;
tempw->next=NULL;
wait_end=tempw;
}
}

void list_piao()
{
int i,j;
for(i=1;i<=m-1;i++)
{
if(a[i].seat[0]!=n)
{
cout<<endl<<"第 "<<i<<" 架飛機剩餘的票 :"<<endl;
for(j=1;j<=n;j++)
if (a[i].seat[j]==0) cout<<" "<<j;
cout<<endl;
}
else cout<<endl<<"The "<<i<<" plane is full !"<<endl<<endl;
}
}
void list_information()
{
int x;
do {cout<<endl<<"顯示哪架飛機的信息 ? "; cin>>x;cout<<endl;}while(x<1 || x>=m);
cout<<endl<<"第 "<<x<<" 架飛機的信息如下 "<<endl;
if(x==1) plane_information(head1);
if(x==2) plane_information(head2);
if(x==3) plane_information(head3);
}

void plane_information(node *head)
{
node *q;
char ch;
int x=0;
if(head!=NULL && head->next!=NULL)
q=head->next;
else {
q=NULL;
cout<<"飛機空,無預訂票 !"<<endl;
}
while(q!=NULL)
{
cout<<endl<<"*******************"<<endl;
q->date=q->plane;
cout<<"日期 :"<<q->date<<endl;
cout<<"座位號 : "<<q->seat<<endl;
cout<<"姓名 : "<<q->name;
cout<<endl<<"ID 號 : "<<q->id;
q=q->next;x++;
if (x % 3 ==0) ch=getch();
}
cout<<endl;
}
void book()
{
int i,j,p;
cout<<endl<<"請選擇地點:(1、2、3) ";
do {
cin>>i;
if (i<1 || i>=m) {
cout<<endl<<"**** 超出范圍!****"<<endl<<"請重新輸入:";
}
else
{cout<<endl<<"你要訂的是到"<<i<<"地的飛機"<<endl;
cout<<endl<<"第 "<<i<<" 架飛機剩餘的票 :"<<endl;
for(p=1;p<=n;p++)
if (a[i].seat[p]==0) cout<<" "<<p;
cout<<endl;
break;}
}while(1);
cout<<endl<<"請選擇座位號 : ";
do {
cin>>j;
if (j<1 || j>n) {
cout<<endl<<"**** 超出范圍!****"<<endl<<"請重新輸入:";
}
else
{
q->date=i;
cout<<endl<<"您的訂票日期 : "<<q->date<<endl;
break;
}
}while(1);

if (a[i].seat[j]==0) {
a[i].seat[j]=1;
cout<<endl;
a[i].seat[0]++;
if(i==1) add_information(head1,1,j);
if(i==2) add_information(head2,2,j);
if(i==3) add_information(head3,3,j);
}
else
{
cout<<endl<<"**** 對不起,該座位已被預訂,您被安排到訂票等候隊列 ****"<<endl;
add_wait(i,j);
}

}
void add_wait(int x,int y)
{
wait *tempw;
tempw=new wait;
tempw->next=NULL;
cout<<"請輸入個人信息"<<endl;
cout<<endl<<"*************"<<endl;
cout<<"姓名 : ";cin>>tempw->name;
cout<<"ID號 : ";cin>>tempw->id;
cout<<"電話 :";cin>>tempw->phone;
tempw->seat=y;
tempw->plane=x;
wait_end->next=tempw;
tempw->pre=wait_end;
wait_end=wait_end->next;
cout<<endl<<"**** 正在排隊等候 ****"<<endl;
wait_head->count++;
write_to_file();
}
void show_wait()
{
wait *tempw;
tempw=wait_head->next;
if (tempw==NULL) cout<<endl<<"排隊中沒有人!"<<endl;
while(tempw!=NULL)
{
cout<<tempw->name<<" - ";
tempw=tempw->next;
}
}
void add_information(node *head,int x,int y)
{
node *temp;
temp=new node;
temp->pre=NULL;
temp->next=NULL;
cout<<"請輸入個人信息"<<endl;
cout<<endl<<"*************"<<endl;
cout<<"姓名 : ";cin>>temp->name;
cout<<"ID號 : ";cin>>temp->id;
temp->seat=y;
temp->plane=x;
temp->next=head->next;
temp->pre=head;
if (head->next!=NULL) head->next->pre=temp;
head->next=temp;
write_to_file();
cout<<endl<<"**** 訂票成功 ****"<<endl;
}
void search_delete(int x)
{
node *p,*q,*r;
wait *tempw,*tempw2,*tempw3;
int step=1,t1,t2,i;
char ch;
p=new node;
tempw=new wait;
tempw2=new wait;
tempw3=new wait;
q=head1;
cout<<endl<<"請輸入個人信息"<<endl;
cout<<"*************"<<endl;
cout<<endl<<"姓名 : ";cin>>p->name;
do{
q=q->next;
if ( (q!=NULL) &&
(comp(q,p)) )
{
cout<<endl;
q->date=q->plane;
cout<<"Located!"<<endl;
cout<<"****************";
cout<<endl<<"姓名 : "<<q->name;
cout<<endl<<"ID號 : "<<q->id;
cout<<endl<<"座位號 : "<<q->seat;
cout<<endl<<"班機號 : "<<q->plane;
cout<<endl<<"日期 : "<<q->date<<endl;
if (x==1) {
cout<<"刪除該紀錄 ? [Y/N] ";
cin>>ch;
if (ch=='Y' || ch=='y') {
t1=q->plane;
t2=q->seat;
a[t1].seat[t2]=0;
a[t1].seat[0]--;
r=q;q=q->pre;
r->pre->next=r->next;
if(r->next!=NULL) r->next->pre=r->pre;
delete(r);
cout<<"**** 記錄刪除成功 ! ****";
write_to_file();
tempw=wait_head;
for(i=0;i<wait_head->count;i++)
{
tempw=tempw->next;
if(tempw==NULL) break;
if((tempw->plane==t1) && (tempw->seat==t2))
{
strcpy(tempw3->name,tempw->name);
strcpy(tempw3->phone,tempw->phone);
cout<<endl<<"等候的人中有可以訂票的了:"<<endl;
cout<<endl<<"姓名 : "<<tempw->name;
cout<<endl<<"ID號 : "<<tempw->id<<endl;
a[t1].seat[0]++;
a[t1].seat[t2]=1;
if(tempw->plane==1) add_information(head1,1,tempw->seat);
if(tempw->plane==2) add_information(head2,2,tempw->seat);
if(tempw->plane==3) add_information(head3,3,tempw->seat);
tempw2=tempw->pre;
tempw2->next=tempw->next;
if(tempw->next==NULL) wait_end=tempw2;
else tempw->next->pre=tempw2;
delete(tempw);
wait_head->count--;
write_to_file();
cout<<endl<<"等候的"<<tempw3->name<<"已經成功訂票,已經由電話"<<tempw3->phone<<"通知了"<<endl;
break;
}
}

}
}continue;
}
else
{
if (q==NULL)
{
step++;
if(step==2) q=head2;
if(step==3) q=head3;
if(step==4) {cout<<endl<<"**** 信息檢索完畢 ****";break;}
}
}
}while(1);
}
bool comp(node *x,node *y)
{
node *p,*q;
int i,j,k;
p=x;
q=y;
i=j=0;
do
{
while ( (p->name[i] != q->name[j]) && (p->name[i] != '\0') ) i++;

if (p->name[i] == '\0') {return(false);break;}
else
{
k=i;
while ( (p->name[k] == q->name[j]) && (q->name[j]!='\0') ) {k++;j++;}
if (q->name[j]=='\0') return(true);
else
{
j=0;
i++;
}
}
}while( (q->name[j]!='\0') && (p->name[i] != '\0') );
return(false);
}

void write_to_file()
{
FILE *fp;
int i,j;
int x[m];
node *p;
wait *tempw;
tempw=new wait;
tempw=wait_head;
fp=fopen("piao.dat","w");
for (i=1;i<=m-1;i++)
{
fwrite(&a[i],sizeof(piao),1,fp);
}
fclose(fp);

fp=fopen("information.dat","w");
x[0]=0;x[1]=a[1].seat[0];
for(i=0,j=1;j<=m-1;j++) {i=i+a[j].seat[0];x[j]=a[j].seat[0]+x[j-1];}
j=1;p=head1->next;
for(j=1;j<=i;j++)
{
if(j==x[1]+1) p=head2->next;
if(j==x[2]+1) p=head3->next;
if(p==NULL)break;
fwrite(p,sizeof(node),1,fp);
p=p->next;
}
fclose(fp);

fp=fopen("wait.txt","w");
for(j=0;j<=wait_head->count;j++)
{
if(tempw==NULL)break;
fwrite(tempw,sizeof(wait),1,fp);
tempw=tempw->next;
}
fclose(fp);
}

『貳』 數據結構課程設計(圖書館借閱管理系統)

圖書借閱管理系統具有以下功能:
圖書資料管理
圖書資料管理主要完成圖書資料的新增、修改和報廢,並生成圖書資料庫的功能。按采購員的要求,供書商提供需要的書籍。進行分類新增修改處理。並對已報廢圖書進行處理。
讀者資料管理
讀者資料管理主要完成讀者資料的新增、修改和撤消,並生成讀者資料庫。按讀者要求進行讀者資料的新增、修改和撤消。
借書操作
借書操作主要完成讀者的借書、續借及預訂處理,並生成讀者借閱庫。首先進行讀者資格的審核,符合要求後查閱書庫是否有書,如有則修改圖書資料庫,書庫取書書交讀者。書庫無書則進行預訂處理。用戶續借則修改還書日期。並將借書信息匯總後交統計員。
還書操作
還書操作主要完成讀者的還書及罰款處理,並修改讀者借閱庫。首先進行讀者資格的審核,符合要求後則修改圖書資料庫,讀者還書書還書庫。書籍逾期或遺失則進行罰款處理。並將還書信息匯總後交統計員。
查詢處理
查詢處理主要完成讀者對書是否逾期、書是否未借、書籍排行榜的查詢處理。並及時地把查詢結果反饋給讀者,並將查詢信息匯總給統計員。
系統維護
包括許可權管理、數據恢復和數據備份。數據恢復和數據備份是對數據的有效保護。許可權管理是對系統使用者規定相關的許可權,以免系統數據被非法訪問和使用。
(訪問時需要密碼,密碼錯誤要有提示重輸,登陸分為管理員登陸和用戶登陸兩項,用戶只能進行查詢操作,而管理員能進行所有操作)
#include <string.h>
#include <iostream.h>

class Book{ // 書籍基類
protected:
char Title[40]; // 書名
long Code; // 條碼
int Type; // 0表示書,1表示雜志
public:
Book();
Book(char *title,long code);
void SetCode(long code){ Code = code; }
void SetTitle(char* tl){ strcpy(Title,tl); }
void SetType(bool type){Type = type; }
int GetType(){ return Type; }
long GetCode(){ return Code;}
virtual void Show(); // 顯示書的信息
friend ostream& operator<<(ostream& , Book&); // 重載插入運算符
friend istream& operator>>(istream& is, Book&); // 重載提取運算符
Book *Next; // 為創建每個讀者所借書鏈表而定義指針
};

class Item :public Book{ //書的款目
// char Title[40]; // 書名
char Author[20]; // 著者名
char IndexCode[10]; // 分類號
// long Code; // 條碼
public:
Item();
Item(char *author,char *title,char *index,int code);
Item(Item &);
void SetAuthor(char*);
void SetIndexCode(char*);
virtual void Show(); // 顯示書的信息
friend ostream& operator<<(ostream& os, Item&); // 重載插入運算符
friend istream& operator>>(istream& is, Item&); // 重載提取運算符
public:

};

class Magazine:public Book { //雜志類
int Volume;
enum LANG {CHINESE=1,ENGLISH} Lang; // 枚舉變數,確定語言類別
public:
Magazine():Book(){Volume = 0; Lang = CHINESE; Type = 1; }
Magazine(char *title,int vol,LANG lang,int code);
Magazine(Magazine&);
void SetVolume(int vol){Volume = vol;}
void SetLang(int lang){Lang = (LANG)lang;}
virtual void Show(); // 顯示雜志的信息
friend ostream& operator<<(ostream& os, Magazine&); // 重載插入運算符
friend istream& operator>>(istream& is, Magazine&); // 重載提取運算符
};

class Reader{ // 讀者信息類

char Name[20]; // 姓名
char Position[20]; // 職務
int Age; // 年齡
long Code; // 借書證號
Book* items; // 所借書鏈表
public:
Reader();
Reader(char *name,char *posi,int age,int code);
// Reader(Reader&);
~Reader();
long GetCode(){return Code;}
void SetName(char*);
void SetPosition(char*);
void SetAge(int);
void SetCode(long);
void AddBook(Item); // 添加所借書
void AddBook(Magazine); // 添加所借雜志
void DelBook(Book it); // 還書後減少所借書
void ShowBooks(); // 顯示所借書
void Show(); // 顯示讀者信息
friend ostream& operator<<(ostream& os, Reader&); // 重載插入運算符
friend istream& operator>>(istream& is, Reader&); // 重載提取運算符
public:
int Counter; //計數器,統計所借書數目
};

class Manager{ // 管理員類
char Name[20]; // 姓名
int Age; // 年齡
int Code; // 工號
friend class Library; // 將圖書館類聲明為友元
public:
Manager(){}
Manager(char*,int,int);
long GetCode(){ return Code;}
void Show();
friend ostream& operator<<(ostream& os, Manager&); // 重載插入運算符
friend istream& operator>>(istream& is, Manager&); // 重載提取運算符
};

class Loan { // 借閱信息類
int Type; // 0表示書,1表示雜志
Item item; // 借閱書
Magazine mag; // 借閱雜志
Reader reader; // 借閱者
Manager manager; // 借書操作員
int Code;
friend class Library; // 將圖書館類聲明為友元
public:
Loan(){ }
Loan(Loan & l);
int GetCode(){ return Code;}
void Show();
friend ostream& operator<<(ostream& os, Loan&); // 重載插入運算符
friend istream& operator>>(istream& is, Loan&); // 重載提取運算符
};
、、、、、、、、、、、、、、、、、、、、、、、
#include<iostream.h>
#include<string.h>
class Reader;
template<typename T> class DblList;
template<typename T> class DblNode{
public:
T Info;//數據域
DblNode<T> *llink,*rlink; //前驅(左鏈)、後繼(右鏈)指針
public:
DblNode(T data);//一般結點
DblNode();//頭結點
T GetInfo(){return Info;};
friend class DblList<T>;
friend class Library;
};

template<typename T>class DblList{
DblNode<T> *head,*current;
public:
DblList();
~DblList();
void Insert(const T& data);
DblNode<T>* Remove(DblNode<T>* p);
void Print();
int Length();//計算鏈表長度
DblNode<T> *Find(T data);//搜索數據與定值相同的結點
DblNode<T>* Find(int data);//按某個關鍵字查找
void MakeEmpty(); //清空鏈表
void ShowList(); //顯示鏈表各結點
friend istream& operator>>(istream&, DblList<typename T>&); // 重載輸入流運算符

friend ostream& operator<<(ostream& os, DblList<typename T>& dlist); // 重載輸出流運算符
friend class Library;
//其它操作
};

template<typename T> DblNode<T>::DblNode(){
llink=rlink=NULL;
}
template<typename T> DblNode<T>::DblNode(T data){
info=data;
llink=NULL;
rlink=NULL;
}

template<typename T> DblList<T>::DblList(){//建立表頭結點
head=new DblNode<T>();
head->rlink=head->llink=head;
current=NULL;
}
template<typename T> DblList<T>::~DblList(){
MakeEmpty();//清空鏈表
delete head;
}
template<typename T> void DblList<T>::MakeEmpty(){
DblNode<T> *tempP;
while(head->rlink!=head){
tempP=head->rlink;
head->rlink=tempP->rlink;//把頭結點後的第一個節點從鏈中脫離
tempP->rlink->llink=head;//處理左指針
delete tempP; //刪除(釋放)脫離下來的結點
}
current=NULL; //current指針恢復
}
template<typename T> void DblList<T>::Insert(const T & data){//新節點在鏈尾
current=new DblNode<T>;
current->Info=data;
current->rlink=head;//注意次序
current->llink=head->llink;
head->llink->rlink=current;
head->llink=current;//最後做
}
template<typename T> DblNode<T>* DblList<T>::Remove(DblNode<T>* p){ // 刪除結點
current=head->rlink;
while(current!=head&¤t!=p) current=current->rlink;
if(current==head) current=NULL;
else{//結點摘下
p->llink->rlink=p->rlink;
p->rlink->llink=p->llink;
p->rlink=p->llink=NULL;
}
return current;
}

template<typename T> DblNode<T>* DblList<T>::Find(T data){ // 按結點查找
current=head->rlink;
while(current!=head&¤t->Info!=data) current=current->rlink;
if(current==head) current=NULL;
return current;
}

template<typename T> DblNode<T>* DblList<T>::Find(int data){ // 按數據值查找結點
current=head->rlink;
int temp =current->Info.GetCode();
while(current!=head&&temp!=data){
current=current->rlink;
temp = current->Info.GetCode();
}
if(current==head) current=NULL;
return current;
}

template<typename T> void DblList<T>::Print(){ // 輸出鏈表
current=head->rlink;
while(current!=head){
cout<<current->Info<<'\t';
current=current->rlink;
}
cout<<endl;
}
template<typename T> int DblList<T>::Length(){ // 取得鏈表長度
int count=0;
current=head->rlink;
while(current!=head){
count++;
current=current->rlink;
}
return count;
}

template<typename T> void DblList<T>::ShowList(){ // 輸出鏈表各結點
int count=0;
current=head->rlink;
while(current!=head){
current->GetInfo().Show();
current=current->rlink;
}
return ;
}

template<typename T>
istream& operator>>(istream& is, DblList<typename T> &dlist){
int len;
T tt; // 定義局部變數讀入一個結點
is>>len;
for(int i= 0 ;i<len; i++){ // 循環讀入鏈表各結點
is>>tt;
dlist.Insert(tt);
}
return is;
}

template<typename T>
ostream& operator<<(ostream& os, DblList<typename T> &dlist){
DblNode<T> *tempP;
int len = dlist.Length();
os<<len<<' ';
tempP=dlist.head->rlink;
while(tempP!=dlist.head){ // 循環輸出鏈表各結點
os<<tempP->Info;
tempP = tempP->rlink;
}
return os;
}
#include "class.h"
#include "dblist.h"
#include <fstream.h>
class Library{ // 封裝圖書館流通業務的類
DblList<Item> item; // 在館圖書鏈表
DblList<Magazine> mag; // 在館雜志鏈表
DblList<Reader> reader; // 讀者鏈表
DblList<Loan> loan; // 借閱信息鏈表
DblList<Manager> manager; // 管理員信息鏈表

int itemNum; // 記錄在館圖書數目
int magNum; // 記錄在館雜志數目
int readerNum; // 記錄讀者數目
int loanNum; // 記錄借閱信息數目
int managerNum; // 記錄管理員數目
ofstream itemFileOut; // 文件流對象,保存圖書館書籍數據
ifstream itemFileIn; // 文件流對象,讀入圖書館書籍數據
ofstream magFileOut; // 文件流對象,保存圖書館雜志數據
ifstream magFileIn; // 文件流對象,讀入圖書館雜志數據
ofstream readerFileOut; // 文件流對象,保存圖書館讀者數據
ifstream readerFileIn; // 文件流對象,讀入圖書館讀者數據
ofstream loanFileOut; // 文件流對象,保存圖書館借閱信息數據
ifstream loanFileIn; // 文件流對象,讀入圖書館借閱信息
ofstream managerFileOut; // 文件流對象,保存圖書館管理員數據
ifstream managerFileIn; // 文件流對象,讀入圖書館管理員數據
public:
Library(); // 構造函數
~Library(); //析構函數
void Run(); // 圖書館類的運行函數
void CreateBibliotheca(); // 創建書目
void CreateReader(); // 創建讀者庫
void CreateManager(); // 創建管理員信息
int ShowMainMenu(); // 顯示主菜單函數
void Borrow(); // 借書操作
void Return(); // 還書操作
void Require(); // 查詢操作
void SaveInfo(); // 保存圖書館信息
void OpenInfo(); // 讀入圖書館信息
};
多給點分吧

『叄』 JAVA數據結構課程設計,航空訂票系統求助


今天比較閑,編了一套,一共4個class。不懂再問。

這格式真要命,湊活看吧。

publicenumAirClass{
FIRST,
SECOND,
THIRD
}

--------------------------------------------


publicclassCustomer{
privateStringname;
privateintticketNumber;
privateAirClassairClass;
publicCustomer(Stringname,intticketNumber,AirClassairClass){
this.name=name;
this.ticketNumber=ticketNumber;
this.airClass=airClass;
}
publicStringgetName(){returnname;}
publicvoidsetName(Stringname){this.name=name;}
publicintgetTicketNumber(){returnticketNumber;}
publicAirClassgetAirClass(){returnairClass;}
}

------------------------------------------------


importjava.util.LinkedList;
importjava.util.List;

publicclassAirLine{
privateStringdestination;
privateStringflightName;
privateStringflightNumber;
privateintdayOfWeek;
privateintcapacity;
privateintremainder;
privateList<Customer>booking=newLinkedList<Customer>();
privateList<Customer>preBooking=newLinkedList<Customer>();

publicAirLine(Stringdestination,StringflightName,StringflightNumber,intdayOfWeek,intcapacity){
this.destination=destination;
this.flightName=flightName;
this.flightNumber=flightNumber;
this.dayOfWeek=dayOfWeek;
this.capacity=capacity;
this.remainder=capacity;}
publicStringgetDestination(){returndestination;}
publicStringgetFlightName(){returnflightName;}
publicStringgetFlightNumber(){returnflightNumber;}
publicintgetDayOfWeek(){returndayOfWeek;}
publicintgetCapacity(){returncapacity;}
publicintgetRemainder(){returnremainder;}
publicList<Customer>getBooking(){returnbooking;}
publicList<Customer>getPreBooking(){returnpreBooking;}

publicbooleanaddBooking(Customerc){
if(this.remainder>=c.getTicketNumber()){
this.remainder=this.remainder-c.getTicketNumber();
this.booking.add(c);
returntrue;
}else{
this.preBooking.add(c);
returnfalse;
}
}

publicvoidremoveBooking(Customerc){
if(this.booking.contains(c)){
this.booking.remove(c);
this.remainder=this.remainder+c.getTicketNumber();
}else{
("Customernotfound.");
}
}

publicvoidremovePreBooking(Customerc){
if(this.preBooking.contains(c)){
this.preBooking.remove(c);
}else{
("Customernotfound.");
}
}

publicStringtoString(){
returnthis.flightName+":"+this.flightNumber+":"
+this.dayOfWeek+":"+this.remainder;
}
}

---------------------------------


importjava.util.Calendar;importjava.util.Date;
importjava.util.LinkedList;importjava.util.List;
importjava.util.concurrent.TimeUnit;

publicclassMain{
privateList<AirLine>airLines=newLinkedList<AirLine>();

privatevoidinit(){
finalAirLineairLine1=newAirLine("beijing","flightName","flightNumber",Calendar.MONDAY,300);
this.airLines.add(airLine1);
//自己加新的airLine2,airLine3...

finalCustomercustomer1=newCustomer("Tom",2,AirClass.FIRST);
airLine1.addBooking(customer1);
//自己加新的customer2,customer3...
}

publicAirLinesearch(Stringdestination){
if(destination==null)returnnull;
finalintcurrenDayOfWeek=Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
AirLineres=null;
intdiffToCurrenDate=7;
for(AirLinea:airLines){
if(destination.equals(destination)){
if(res==null){
res=a;
continue;
}
intdiff=a.getDayOfWeek()-currenDayOfWeek;
if(diff<0)diff=diff+7;
if(diff<diffToCurrenDate){
diffToCurrenDate=diff;
res=a;
}
}
}
if(res==null){
System.out.println("Notfound");
}else{
System.out.println("日期"+newDate(System.currentTimeMillis()+TimeUnit.DAYS.toMillis(diffToCurrenDate))+":"+res.toString());
}
returnres;
}

publicvoidbooking(AirLinea,Customerc){
if(a.addBooking(c)){
System.out.println("訂到了");
}else{
System.out.println("排隊中");
}
}

publicvoidcancel(AirLinea,Customerc){
a.removeBooking(c);
for(Customerpre:a.getPreBooking()){
if(a.addBooking(pre)){
a.removePreBooking(pre);
System.out.println("排隊的訂到了");
break;
}else{
System.out.println("票餘量不夠當前面排隊的人,下一個");
}
}
}
}

『肆』 圖書管理系統--數據結構課程設計

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

struct BOOK
{
int id,usr[10],total,store,days[10];
char name[30],author[20];
}books[100];
/*結構體,存放書籍及借書信息。*/

void page_title(char *menu_item)
{
printf(">>> 以下是圖 書 管 理 系 統--請 按 要 求 操 作 <<<\n\n- %s -\n\n",menu_item);
}
/*頁頭函數,可以通過參數menu_item,顯示當前狀態。*/

void return_confirm(void)
{
printf("\n任意鍵返回……\n");
getch();
}
/*返回前請求確認函數,方便返回前觀察結果*/

int search_book(void)
{
int n,i;
printf("請輸入圖書序號:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("書名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存數:%d\n",books[n].store);
printf("總數:%d\n",books[n].total);
return n;
}
}
printf("\n輸入有錯或圖書序號不存在.\n");
return -1;
}
/*上面是在數組中找到圖書號匹配的記錄,顯示其信息並返
回數組下標,如果找不到相應記錄則提示錯誤並返回-1。*/

void book_out(void)
{
int n,s,l,d;
page_title("借書");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("請輸入借書證序號:");
scanf("%d",&s);
printf("請輸入可借天數:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此書已經全部借出.\n");
return_confirm();
}
/*借書的函數,首先調用找書函數*/

void book_in(void)
{
int n,s,l;
page_title("還書");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借閱者圖書證列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("請輸入借書證序號:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}

void book_add(void)
{
int n;
page_title("注冊書");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序號:");
scanf("%d",&books[n].id);
printf("書名:");
scanf("%s",&books[n].name);
printf("作者:");
scanf("%s",&books[n].author);
printf("數量:");
scanf("%d",&books[n].total);
books[n].store=books[n].total;
return_confirm();
}

void book_del(void)
{
int n;
page_title("注銷書");
if((n=search_book())!=-1) books[n].id=0;
printf("該書已注銷.\n");
return_confirm();
}

void main(void)
{
menu: page_title("操作選擇單子");
printf("請按以上要求選擇操作\n\n");
printf("1 借書\n2 還書\n\n");
printf("3 注冊書\n4 注銷書\n\n");
printf("\n0 退出\n");
switch(getch())
{
case '1' : book_out();break;
case '2' : book_in();break;
case '3' : book_add();break;
case '4' : book_del();break;
case '0' : exit(0);
}
goto menu;
}

『伍』 數據結構課程設計訂票系統運用到的演算法思想是什麼急

隊列的演算法思想吧

『陸』 數據結構課程設計……關於飛機票系統 哪位高手幫我做做啊

汗,難道這個課的老師不能換點題材嗎?當年我們也是寫這個,還要答辯.....
用VB寫下很簡單的啊樓主,看你的要求還沒涉及到網路聯機...當初我們寫的時候要求最少2電腦,一台寫伺服器,一台寫客戶端,實現查詢、定退票....許可權等等....比較煩,你這個自己寫下吧!

建議最少給100分,可能有人會幫你寫,即便是這樣的功能,少說也有1000行代碼了!

『柒』 數據結構課程設計 鐵路票務管理系統

#include<fstream>
#include<iostream>
#include<string>
#include<stdio.h>
#include<iomanip>
#define SIZE_view 50
#define SIZE_line 100
#define SIZE_way 300

#define MAXNODE 30 //定義最多的頂點數
#define MAXCOST 1000
//自己寫的頭文件
//#include<addview.h>// //

using namespace std;

struct view_info /*城市信息結構*/
{
int id;
char name[20];
int code;
char shortname[20];
char LName[100];// 經過此車站的鐵路線名稱
} views[SIZE_view];

struct line_info //鐵路線信息結構
{
int Lid;
char LName[20];
int start_id; //始發站id
int end_id; //終點站id
int dist; //鐵路線長度
int sign;//通行標志
}lines[SIZE_line];

struct way_info //鐵路度的信息結構
{
int station1;
int station2;
int dist;
}ways[SIZE_way];

struct path_info //用於最短路徑的查詢

{
int count;
int path[SIZE_view];
};

int view_count,line_count,way_count;//用來存儲文件中有多少條記錄

void readviews()
{
int i;
ifstream infile("views.txt",ios::in); //打開文件
infile >>view_count ; //把文件中的記錄賦值給view_count
if(!infile) //打開文件失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
//infile>>view_count; // 先讀入文件個數
for(i=0;i<view_count;i++)
{
infile>>views[i].id>>views[i].name>>views[i].code>>views[i].shortname>>views[i].LName;

}
//view_count=i;//給出原文件中車站的個數
infile.close();
cout<<" "<<"id"<<" "<<"name"<<" "<<"code"<<" "<<"shortname"<<" "<<"LName"<<endl;
for(i=0;i<view_count;i++)
cout<<" "<<views[i].id<<" "<<views[i].name<<" "<<views[i].code
<<" "<<views[i].shortname<<" "<<views[i].LName<<endl;

}

void readways() //讀文件ways.txt
{
int i;
ifstream infile("ways.txt",ios::in); //打開文件
infile>>way_count; ////把文件中的記錄賦值給way_count
if(!infile) //打開文件失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<way_count;i++)
infile>>ways[i].station1>>ways[i].station2>>ways[i].dist;
infile.close();
//測試用,輸出路段的信息
cout<<" "<<"station1"<<" "<<"station2"<<" "<<"dist"<<endl;
for(i=0;i<way_count;i++)
cout<<" "<<ways[i].station1<<" "<<ways[i].station2<<" "<<ways[i].dist<<endl ;

}

void readlines() //讀文件lines.txt
{
int i;
ifstream infile("lines.txt",ios::in); //打開文件
infile>>line_count; //把文件中的記錄賦值給line_count
if(!infile) //打開文件失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
for(i=0;i<line_count;i++)
infile>>lines[i].Lid>>lines[i].LName>>lines[i].start_id>>lines[i].end_id>>lines[i].dist>>lines[i].sign;
infile.close();

/*
cout<<" "<<"Lid"<<" "<<"LName"<<" "<<"start_id"<<" "<<"end_id"<<" "<<"dist"<<" "<<"sign"<<endl;
for(i=0;i<view_count;i++)
cout<<" "<<lines[i].Lid<<" "<<lines[i].LName<<" "<<lines[i].start_id
<<" "<<lines[i].end_id<<" "<<lines[i].dist<<" "<<lines[i].sign<<endl;

*/ //這里是輸出文件中的信息

}

void search () //查詢車站信息(所在的鐵路線)
{
cout<<"please enter the station name:";
char sta_name[20];
cin>>sta_name; //輸入要查詢的名字
cout<<endl;
ifstream infile("views.txt ",ios::in); //讀文件
infile >>view_count ; //讀出文件記錄的個數
if(!infile) //打開文件失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
int i,mark;
for(i=0;i<view_count;i++)
infile>>views[i].id>>views[i].name>>views[i].code>>views[i].shortname>>views[i].LName;
infile.close();
for(i=0;i< view_count;i++)
{
if(strcmp(sta_name,views [i].name)==0) //找到車站
{
cout<<"the station's informations is:\n"<<endl;
cout<<" "<<"id"<<" "<<"name"<<" "<<"code"<<" "<<"shortname"<<" "<<"LName"<<endl;
cout<<" "<<views[i].id<<" "<< views[i].name<<" "<< views [i].code
<<" "<< views [i].shortname<<" "<< views [i].LName <<endl;
break;
}
mark=i;

}
if(mark==( view_count -1)) //若沒有找到,輸出提示
{
cout<<"sorry,the station is not in here"<<endl;
}
}

void addview()
{
cout<<"please enter the new view's informations:"<<endl; //輸入新車站信息
cout<<"id:";
cin>>views[view_count].id;
cout<<"name:";
cin>>views[view_count].name;
cout<<"code:";
cin>>views[view_count].code;
cout<<"shortname:";
cin>>views[view_count].shortname;
cout<<"LName:";
cin>>views[view_count].LName;

ofstream outfile("views.txt",ios::app); //打開views文件,並且寫入數據
outfile<<view_count<<endl;
if(!outfile) //文件打開失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<views[view_count].id<<" "<<views[view_count].name<<" "<<views[view_count].code
<<" " <<views[view_count].shortname<<" "<<views[view_count].LName<<endl;
//在文件末尾添加
view_count=view_count+1;

outfile.close(); //關閉文件
cout<<"successfully! the new station is added"<<endl;
cout<<"now station number is:"<<view_count<<endl;

}

void addway()
{
cout<<"please enter the new way's informations:"<<endl; //輸入新車站信息
cout<<"station1:";
cin>>ways[way_count].station1; // station1的id
cout<<"station2:";
cin>>ways[way_count].station2; //station2的id
cout<<"dist:";
cin>>ways[way_count].dist; //路段的長度

ofstream outfile("ways.txt",ios::app); //打開way.txt文件
outfile<<way_count<<endl;
if(!outfile) //文件打開失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<ways[way_count].station1<<" "<<ways[way_count].station2<<" "<<ways[way_count].dist;
//在文件末尾添加

outfile.close(); //關閉文件
cout<<"successfully! the new station is added"<<endl;
way_count=way_count+1;
cout<<"now station number is:"<<view_count<<endl;

}

void addline()
{
cout<<"please enter the new line's informations:"<<endl; //輸入新鐵路線信息
cout<<"Lid:";
cin>>lines[line_count].Lid;
cout<<"LName:";
cin>>lines[line_count].LName;
cout<<"start_id:";
cin>>lines[line_count].start_id;
cout<<"end_id:";
cin>>lines[line_count].end_id;
cout<<"dist:";
cin>>lines[line_count].dist;
cout<<"sign:";
cin>>lines[line_count].sign;

ofstream outfile("lines.txt",ios::app); //打開文件
outfile <<line_count << endl;
if(!outfile) //文件打開失敗
{
cerr<<"open error!"<<endl;
exit(1);
}
outfile<<lines[line_count].Lid<<" "<<lines[line_count].LName<<" "<<lines[line_count].start_id
<<" " <<lines[line_count].end_id<<" "<<lines[line_count].dist<<lines[line_count].sign<<endl;
//在文件末尾添加

outfile.close(); //關閉文件
cout<<"successfully! the new line is added"<<endl;
line_count=line_count+1;
cout<<"now line number is:"<<line_count<<endl;

}

//-----------------------------------------------------------------------------------

void floyed() //弗洛伊德(Floyed)演算法
{

int i, j, k, m, start_num, end_num; //i,j用來表示起始點和終點
int dist_list[SIZE_view][SIZE_view]; //定義了一個數組
view_count=view_count+1;
struct path_info path_list[SIZE_view][SIZE_view]; //定義了一個path_info結構的變數,包含著count和path[]用來存儲經過的路徑
for(i=1;i<=view_count;i++) //這里開始讀文件,先讓所有的線都為最大值
for(j=1;j<=view_count;j++)
dist_list[i][j]=MAXCOST;

for(int t=0;t<=way_count;t++)
{
i=ways[t].station1;
j=ways[t].station2;
dist_list[i][j]=ways[t].dist;//把文件中的數據賦值給dist_list[i][j]=ways[t].dist;形式

}

for (i =0; i< view_count; i++)
{
for (j= 0; j<view_count; j++)
{
if (i == j)
{
dist_list[i][j] = 0;
continue;
}

dist_list[i][j] = -1;
path_list[i][j].count = 0;
for (k = 0; k< way_count; k++) //
{
if (ways[k].station1 == i && ways[k].station2 == j) //把起始點和終點分別給予i,j

{
dist_list[i][j] = ways[k].dist;
path_list[i][j].count = 2;
path_list[i][j].path[0] = i;
path_list[i][j].path[1] = j;
break;
}

}

}

}

for (k = 0; k<= view_count-1; k++)
{
for (i = 0; i < view_count; i++)
for (j = 0; j< view_count; j++)
{
if (i == k || j == k || i == j)
continue;
if (dist_list[i][k] == -1 || dist_list[k][j] == -1)
continue;
if ( (dist_list[i][j] == -1) ||
((dist_list[i][j] != -1) &&(dist_list[i][k] + dist_list[k][j] < dist_list[i][j])))
{
dist_list[i][j] = dist_list[i][k] + dist_list[k][j];
// shortest[i][j]=shortest[i][k]+shortest[k][j];
path_list[i][j].count = path_list[i][k].count + path_list[k][j].count - 1;
// path[i][j]=k;
for (m = 0; m < path_list[i][k].count; m++)
path_list[i][j].path[m] = path_list[i][k].path[m];
for (m = 0; m < path_list[k][j].count; m++)
path_list[i][j].path[m+path_list[i][k].count] = path_list[k][j].path[m+1];

}

}
}

cout<<" Floyed table:\n";
cout<<" All views in the school:\n";
for (i = 0; i < view_count-1; i++)
cout<<" "<<i+1<<":"<<views[i].name<<endl;

cout<<" Please input the start number: ";
cin>>start_num;
cout<<" Please input the end number: ";
cin>>end_num;
cout<<endl<<endl;

cout<<"From"<<views[start_num-1].name<<"to"<<views[end_num-1].name;
if (dist_list[start_num][end_num] == -1)
cout<<"no way."<<endl;
else
{
cout<<"distance is "<<dist_list[start_num][end_num]<<", and path is :";//dist_list[][]用來表示兩點間的長度
k = path_list[start_num][end_num].path[0]-1; //path_list[][]用來保存路徑path[m]在這里表明是通過的那個車站的
cout<<views[k].name;
for (m = 1; m < path_list[start_num][end_num].count; m++)
{
k = path_list[start_num][end_num].path[m]-1; //這里應該也是int型,k是經過的路徑的id
cout<<"->"<<views[k].name;
}
}
cout<<endl<<endl;
}

void main()
{
readviews();
readlines() ;
readways();

while(1)
{

int menu;
cout<<endl<<endl<<endl<<endl;
cout<<" 全國鐵路運輸網最佳經由系統 "<<endl;
cout<<"**********************************************************"<<endl;
cout<<" 1:增加車站信息 "<<endl;
cout<<" 2:增加鐵路線信息 "<<endl;
cout<<" 3:查詢車站信息 "<<endl;
cout<<" 4:查詢最短路徑 "<<endl;
cout<<" 5:退出界面 "<<endl;
cout<<"**********************************************************"<<endl;

cout<<"輸入要進行的操作的代碼(1--5):"<<endl;
cin>>menu;
while(menu<1||menu>5)
{
cout<<"error!please enter again:";
cin>>menu;
}
switch(menu)
{
case 1:
while(1)
{
addview();
while (1)
{
addway();
cout<<"do you want to continue (y/n) "<<endl;
char con ;
cin>>con;
if(con=='y')
addway();
else
break;

}
cout<<"do you want to continue (y/n) "<<endl;
char con ;
cin>>con;
if(con=='y')
addview();
else
break;

}

break;
case 2:
while(1)
{
addline();
cout<<"do you want to continue (y/n) "<<endl;
char con ;
cin>>con;
if(con=='y')
addline();
else
break;

}

break;

case 3:
while(1)
{
search ();
cout<<"do you want to continue (y/n) "<<endl;
char con ;
cin>>con;
if(con=='y')
search ();
else
break;

}

break;
case 4:
while(1)
{
floyed();
cout<<"do you want to continue (y/n) "<<endl;
char con ;
cin>>con;
if(con=='y')
floyed();
else
break;

}

break;
case 5:
{
cout<<"謝謝使用,再見!"<<endl;
exit(1);
}

}
}
}

『捌』 數據結構課程設計——航空訂票系統(C語言)

1、任務:航空客運定票的業務活動包括:查詢航線、客票預定和辦理退票等。試設計一個航空客運定票系統,以使上述業務可以藉助計算機來完成。 2、功能要求: 1) 錄入:可以錄入航班情況(數據可以存儲在一個數據文件中,數據結構、具 體數據自定) 2) 查詢:可以查詢某個航線的情況(如,輸入航班號,查詢起降時間,起飛抵 達城市,航班票價,票價折扣,確定航班是否滿倉);可以輸入起飛抵達城市, 查詢飛機航班情況; 3) 訂票:(訂票情況可以存在一個數據文件中,結構自己設定)可以訂票,如果 該航班已經無票,可以提供相關可選擇航班; 4) 退票: 可退票,退票後修改相關數據文件; 5) 客戶資料:有姓名,證件號,訂票數量及航班情況,訂單要有編號; 6) 修改航班信息:當航班信息改變可以修改航班數據文件。 3、要有一個好的界面~~~~~~~~~~~~~~~~~~~~~~~~4、需求分析 系統需求(系統要求實現的功能的具體情況)5、 概要設計 系統分析(分析系統的功能和具體模塊的劃分) 系統流程(系統的流程圖) 程序詳細代碼:

『玖』 求一份學生管理系統課程設計報告,數據結構課程設計

|」

為什麼要中間拿那麼多空格隔開呢?逗號或「|」都比那好弄。

如果這題是老師出的,老師一定腦袋有問題。

//==============

效果圖查詢自己寫

需要的控制項

private System.Windows.Forms.Button button1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RichTextBox richTextBox2;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox3;

後台

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class cj : Form
{
public StreamWriter SW;
public cj()
{
InitializeComponent();
string Header = "姓名" + " " + "學號" + " " + "語文" + " " + "數學" + " " + "英語" + " ";
richTextBox1.AppendText(Header);
richTextBox2.AppendText(Header);
CheckDirectory();
}

private void button1_Click(object sender, EventArgs e)
{
string strFile;
strFile = System.Windows.Forms.Application.StartupPath + "\3.txt";
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "文本文件(*.txt)|*.txt";
openFileDialog1.DefaultExt = "txt";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string FileName = openFileDialog1.FileName;

if (Path.GetExtension(FileName) != ".txt")
{
MessageBox.Show("格式不對");
}
else
{

FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
StreamReader sReader = new StreamReader(openFileDialog1.FileName, Encoding.Default);
if (sReader.ReadLine().Split(' ').Length > 0)
{
richTextBox1.AppendText(sReader.ReadToEnd());
}
richTextBox1.AppendText(" ");

// StreamWriter ssw = new System.IO.StreamWriter(FileName, true, System.Text.Encoding.Default);


}


}

}


private void WriteLog(string msg)
{
string strFile;
strFile = System.Windows.Forms.Application.StartupPath + "\data\3.log";
// StreamWriter SW;
try
{
SW = new System.IO.StreamWriter(strFile, true);


SW.WriteLine(msg);
}
catch (Exception ex)
{
WriteLog(ex.Message);
}
finally
{
SW.Flush();
SW.Close();
}

}

private void button2_Click(object sender, EventArgs e)
{
richTextBox1.Text = "姓名" + " " + "學號" + " " + "語文" + " " + "數學" + " " + "英語" + " ";
}

private void CheckDirectory()
{

if (Directory.Exists(System.Windows.Forms.Application.StartupPath + "\data") == false)
{
Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\data");
}
if (Directory.Exists(System.Windows.Forms.Application.StartupPath + "\data") == false)
{
Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + "\data");
}
}

private void button3_Click(object sender, EventArgs e)
{
string rowdata = "";


int m = richTextBox1.Lines.Length;
string[] lines = new string[m];
for (int i = 1; i < m-1; i++) //每一行
{
lines[i] = richTextBox1.Lines[i]+" ";

string[] cj = lines[i].Split(' ');


if (cj != null)
{
rowdata = " ";
for (int j = 0; j < cj.Length; j++) //每一列
{
if (cj[j].ToString() != "")
{
rowdata = rowdata + cj[j].ToString()+",";
}

}
rowdata.TrimEnd(',');

string[] ncj = rowdata.Split(',');

string str2 = ncj[2].ToString();
string str3 = ncj[3].ToString();
string str4 = ncj[4].ToString().TrimEnd(' ');

// if ((int.Parse(str2) + int.Parse(str3) + int.Parse(str4) < 180))
if ((int.Parse(str2)<60 || int.Parse(str3)<60 || int.Parse(str4) < 60))
{
richTextBox2.AppendText(lines[i]);
}

}



}


if (File.Exists(System.Windows.Forms.Application.StartupPath + "\data\3.txt") == true)
{
File.Delete(System.Windows.Forms.Application.StartupPath + "\data\3.txt");
}
File.AppendAllText(System.Windows.Forms.Application.StartupPath + "\data\3.txt", richTextBox1.Text);


if (File.Exists(System.Windows.Forms.Application.StartupPath + "\data\4.txt") == true)
{
File.Delete(System.Windows.Forms.Application.StartupPath + "\data\4.txt");
}
File.AppendAllText(System.Windows.Forms.Application.StartupPath + "\data\4.txt", richTextBox2.Text);



MessageBox.Show("數據合成OK,在data文件夾");
}

}
}

『拾』 數據結構課程設計:電費核算系統

數據結構是計算機存儲、組織數據的方式。數據結構是指相互之間存在一種或多種特定關系的數據元素的集合。通常情況下,精心選擇的數據結構可以帶來更高的運行或者存儲效率。
一、數據的邏輯結構:指反映數據元素之間的邏輯關系的數據結構,其中的邏輯關系是指數據元素之間的前後件關系,而與他們在計算機中的存儲位置無關。邏輯結構包括:
1.集合結構
數據結構中的元素之間除了"同屬一個集合" 的相互關系外,別無其他關系;
2.線性結構
數據結構中的元素存在一對一的相互關系;
3.樹形結構
數據結構中的元素存在一對多的相互關系;
4.圖形結構
數據結構中的元素存在多對多的相互關系。
二、數據的物理結構:指數據的邏輯結構在計算機存儲空間的存放形式。
數據的物理結構是數據結構在計算機存儲器中的具體實現,是邏輯結構的表示(又稱存儲映像),它包括數據元素的機內表示和關系的機內表示。由於具體實現的方法有順序、鏈接、索引、散列等多種,所以,一種數據結構可表示成一種或多種存儲結構。
數據元素的機內表示(映像方法): 用二進制位(bit)的位串表示數據元素。通常稱這種位串為節點(node)。當數據元素有若干個數據項組成時,位串中與個數據項對應的子位串稱為數據域(data field)。因此,節點是數據元素的機內表示(或機內映像)。
關系的機內表示(映像方法):數據元素之間的關系的機內表示可以分為順序映像和非順序映像,常用兩種存儲結構:順序存儲結構和鏈式存儲結構。順序映像藉助元素在存儲器中的相對位置來表示數據元素之間的邏輯關系。非順序映像藉助指示元素存儲位置的指針(pointer)來表示數據元素之間的邏輯關系。

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919