通過學習學生資訊管理系統軟體,C程式中,如何設計和編寫一個應用系統?

來源:互聯網
上載者:User

標籤:管理系統   include   學生登入   public   amount   

1· 要做一個學生資訊管理系統,首先這個系統要方便操作,登入到系統後學生的資訊一目瞭然

2·1)用自訂結構體設計該系統的資料連線

  2)用數組或指標鏈表將所有學生的資料按學號順序連結起來

  3)程式能夠顯示已經輸入的指定學號學生的個人資訊

3·該結構系統學生登入能夠查看資料,教師登入不僅能查看資料還能修改資料。

設計產品管理系統

1·產品需求分析

2·概要設計

3·詳細設計

4·編寫代碼

5·程式分析

超市商品管理系統

# include <iostream># include <fstream># include <string.h>#include <conio.h>//用getch();using namespace std;//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌commodity類﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌class commodity{public: char name[20]; char Id[20]; int buy;//進貨價; int sale;//賣出價; int amount;//數量; int sum;//利潤; commodity * Next; void Input() {  cout<<"\t\t請輸入商品的名稱:";  cin>>name;  cout<<"\t\t請輸入商品的編號:";  cin>>Id;  cout<<"\t\t請輸入進貨價:"; cin>>buy;  cout<<"\t\t請輸入售出價:"; cin>>sale;  cout<<"\t\t請輸入商品數量:"; cin>>amount;  sum=(sale-buy)*amount; } void ReadFile(istream & in) {  in>>name>>Id>>sale>>buy>>sum; } void Show() {  cout<<"商品名"<<name<<endl<<"編號:"<<Id<<endl<<"進貨價"<<buy<<"售出價"<<sale<<"商品數量:"<<  amount<<"預計總利潤:"<<sum<<endl<<endl<<endl; }};//﹌﹌﹌﹌﹌﹌﹌﹌﹌Commoditymassage類﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌class Commoditymassage{public: Commoditymassage(); ~Commoditymassage(); void ShowMenu(); void Find(); void Save(); void ModifyItem(); void RemoveItem(); void Swap(commodity *,commodity *); void Sort(); int ListCount(); void Display() {  for(commodity * p=Head->Next;p!=End;p=p->Next)   p->Show();  cout<<"輸入任一字元!繼續……";  getch(); } void AddItem() {  End->Input();  End->Next=new commodity;  End=End->Next;  cout<<"添加成功!"<<endl;  cout<<"輸入任一字元!繼續……";  getch(); }private: commodity * Head,* End; ifstream in; ofstream out; commodity *FindItem(char * name) {  for(commodity * p=Head;p->Next!=End;p=p->Next)//匹配成功則返回上一個指標,不成功就返回空   if(!strcmp(p->Next->name,name))return p;   return NULL; } commodity *FindID(char * Id) {  for(commodity * p=Head;p->Next!=End;p=p->Next)//匹配成功則返回上一個指標,不成功就返回空   if(!strcmp(p->Next->Id,Id))return p;   return NULL; }};//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌Commoditymassage::Commoditymassage(){ Head=new commodity; Head->Next=new commodity; End=Head->Next; in.open("sort.txt"); if(!in)  cout<<"無商品資訊。請先輸入。"<<endl; else {  while(!in.eof())  {   End->ReadFile(in);   if(End->name[0]==‘\0‘)break;   End->Next=new commodity;   End=End->Next;  }  in.close();  cout<<"\t\t讀取商品資訊成功!"<<endl; }}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌解構函式﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌Commoditymassage::~Commoditymassage(){ Save(); for(commodity * temp;Head->Next!=End;) {  temp=Head->Next;  Head->Next=Head->Next->Next;  delete temp; } delete Head,End;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌菜單﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::ShowMenu()                  {  cout<<"〓〓〓〓〓〓〓〓〓〓  ☆   超 市 商 品 管 理 系  統     ☆  〓〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓★★★★★         ★★★★★★★         ★★★★★〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          1.增加超市商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          2.顯示超市商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          3.排序統計商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          4.尋找超市商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          5.刪除超市商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          6.修改超市商品        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"〓〓〓〓〓〓〓〓〓★  ☆          0.安全退出系統        ☆  ★〓〓〓〓〓〓〓〓〓"<<endl;  cout<<"\n\t\t\n\t\t請選擇:";}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌尋找函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::Find(){ char name[20] ,Id[10]; int x; commodity * p=NULL; cout<<"\n\t\t*********************************\n"; cout<<"\t\t※ 1.按商品的名稱尋找\n\t\t※ 2.按商品編號尋找"; cout<<"\n\t\t*********************************\n請選擇:"; cin>>x; switch(x) { case 1:{cout<<"\t\t請輸入要尋找的商品的名稱:";cin>>name;  if(p=FindItem(name))  {   p->Next->Show();   cout<<"輸入任一字元!繼續……";   getch();  }  else  {   cout<<"\t\t沒有找到該名稱的商品!"<<‘\n‘<<endl;   cout<<"輸入任一字元!繼續……";   getch();  }     }break; case 2:  {   cout<<"\t\t請輸入要尋找的商品的編號:";cin>>Id;   if(p=FindID(Id))   {    p->Next->Show();    cout<<"輸入任一字元!繼續……";    getch();   }   else   {    cout<<"\t\t沒有找到該編號的商品!"<<‘\n‘<<endl;    cout<<"輸入任一字元!繼續……";    getch();   }  }break; } }//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌修改商品資訊﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::ModifyItem()     //修改商品資訊{ char name[20]; commodity * p=NULL; cout<<"\t\t請輸入要修改的商品的名稱:";cin>>name; if(p=FindItem(name)) {  cout<<"\t\t已找到商品的資訊,請輸入新的資訊!"<<endl;  p->Next->Input();  cout<<"修改成功!"<<endl;  cout<<"輸入任一字元!繼續……";  getch(); } else {  cout<<"\t\t沒有找到!"<<endl;  cout<<"輸入任一字元!繼續……";  getch(); }}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌刪除資訊﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::RemoveItem()         // 刪除資訊{ char name[20]; commodity * p=NULL,*temp=NULL; cout<<"\t\t請輸入要刪除的商品的名稱:"<<endl;cin>>name; if(p=FindItem(name)) {  temp=p->Next;  p->Next=p->Next->Next;   delete temp;  cout<<"\t\t刪除成功!"<<endl;  cout<<"輸入任一字元!繼續……";  getch(); } else {  cout<<"\t\t沒有找到!"<<endl;     cout<<"輸入任一字元!繼續……";  getch(); }}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::Swap(commodity *p1, commodity *p2)//交換兩個combox變數的資料域{ commodity *temp=new commodity;  strcpy(temp->name,p1->name); strcpy(temp->Id,p1->Id); temp->sale=p1->sale; temp->buy=p1->buy; temp->sum=p1->sum;  strcpy(p1->name,p2->name); strcpy(p1->Id,p2->Id); p1->sale=p2->sale; p1->buy=p2->buy; p1->sum=p2->sum;  strcpy(p2->name,temp->name); strcpy(p2->Id,temp->Id); p2->sale=temp->sale; p2->buy=temp->buy; p2->sum=temp->sum;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌int Commoditymassage::ListCount()//統計當前鏈表的記錄總數,返回一個整數{ if(! Head)  return 0; int n=0; for(commodity * p=Head->Next;p!=End;p=p->Next) {  n++; } return n;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::Sort()//對當前鏈表進行排序{  cout <<"Sorting..."<<endl; commodity *p=NULL,*p1=NULL,*k=NULL; int n=Commoditymassage::ListCount(); if(n<2)   return; for(p=Head->Next;p!=End;p=p->Next)  for(k=p->Next;k!=End;k=k->Next)  {   if(p->sum>k->sum)   {    Commoditymassage::Swap(p,k);   }  } cout <<"排序完成!"<<endl; getch(); return;}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌儲存函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌void Commoditymassage::Save(){ out.open("sort.txt"); for(commodity *p=Head->Next;p!=End;p=p->Next)  out<<p->name<<"\t"<<p->Id<<"\t"<<p->sum<<‘\n‘; out.close();}//﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌主函數﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌int main(){ int x,i=0; bool quit=false; cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§"<<endl; for(i=0;i<3;i++)  cout<<"\t\t◎\t\t\t\t\t\t  ◎"<<endl; cout<<"\t\t◎★★★★【  歡迎進入超市商品管理系統  】★★★★◎"<<endl; for(i=0;i<3;i++)  cout<<"\t\t◎\t\t\t\t\t\t  ◎"<<endl; cout<<"\t\t§§§§§§§§§§§§§§§§§§§§§§§§§§\n"<<endl;; Commoditymassage Grade; cout<<"按任意鍵開始……";  getch(); while(!quit) {  system("cls");  Grade.ShowMenu();  cin>>x;  switch(x)  {  case 0:quit=true;break;  case 1:Grade.AddItem();break;  case 2:Grade.Display();break;  case 3:Grade.Sort();break;  case 4:Grade.Find();break;  case 5:Grade.RemoveItem();break;  case 6:Grade.ModifyItem();break;  } } return 0;

150809324


本文出自 “11493624” 部落格,謝絕轉載!

通過學習學生資訊管理系統軟體,C程式中,如何設計和編寫一個應用系統?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.