leilast
یک شنبه 17 تیر 1386, 18:30 عصر
سلام
این پروژه مربوط به یک بانک سی دیه.
کسی میتونه برام درستش کنه؟
enter:کد سی دی را میگیرد و به لیست پیوندی به صورت مرتب اضافه میکند
del:حذف سی دی پس از یافتن آن
searcha:جستجو بر اساس موضوع ونمایش نتیجه آن
searchb:جستجو بر اساس نام سی دی ونمایش آن
get:امانت سی دی و کم کردن یک واحد از موجودی سی دی
ret:برگشت سی دی و اضافه کردن یک واحد به موجودی
show:نمایش تمام گره ها پس از انجام تغییرات
#include "conio.h"
#include "iostream.h"
#include "string.h"
#include "stdio.h"
class node {// ***********************************************
friend class cdbank;
int id;
char name[20];
char subject[20];
int num;
int date;
int other;
char exp[50];
class node* next;};
class cdbank{//********************************************
friend class node;
public:
cdbank();
~cdbank();
void show();
void enter();
void del();
void searcha();
void searchb();
void ret();
void get();
private:
node *first;};//*************************************
cdbank::cdbank(){
first='\0';}
cdbank::~cdbank(){ //**********************************
node *p;
p=first;
while(first!='\0'){
first=p->next;
delete p;
p=first;}}
void cdbank::show(){ //********************************
node *p;
p=first;
while(p){
p=p->next;
cout<<p->id<<p->name<<p->subject<<p->date<<p->other<<p->exp;}}
void cdbank::enter(){//***************************************
node *p,*q,*t;
int n,i;
cout<<"please enter n";
cin>>n;
for(i=0;i<=n;++i){
p=new node;
cout<<"p->id";
cin>>p->id;
if(p->id<1000)
cout<<"error";
else{
cout<<"your id is right";
cout<< "p->name"<<"p->subject"<<"p->date"<<"p->other"<<"p->exp";
cin>>p->id>>p->name>>p->subject>>p->date>>p->other>>p->exp;
p->next='\0';
if(!first)
first=p;
else{
q=first;
while(q&&q->id<p->id){
t=q;
q=q->next;}
if(q==first){
p->next=first;}
else{
p->next=t->next;
t->next=p;
}}}}
void cdbank::del(){ //***************************************
int cnt,j,idd;
node *p,*q;
cout<<"please enter cnt";
cin>>cnt;
for(j=0;j<=cnt;++j){
cout<<"enter idd";
cin>>idd;
p=first;
while(p){
p=p->next;
if(p->id=idd)
if(p=first)
first= p->next;
else
q->next=p->next;}}}
delete p;} //************************************************
void cdbank::searcha(){//namayesh gere ba mozoue morede nazar
node *p;
char s[20];
cout<< "s";
cin>>s;
p=first;
while(p){
p=p->next;
if(strcmp(s,p->subject)== 0)
cout<<p->id<<p->name<<p->subject<<p->date<<p->exp;
else
cout<<"your s not found";}}
void cdbank::searchb(){ //************************************
node *p;
char n[20];
cout<<"n";
cin>>n;
p=first;
while(p){
p=p->next;
if(strcmp(n,p->name)==0)
cout<<p->id<<p->name<<p->subject<<p->date<<p->exp;
else
cout<<"your n not found";}}
void cdbank::get(){ //******************************************
int id;node *p;
cout<<"id";
cin>>id;
p=first;
while (p){
p=p->next;
if(p->id==id){
p->other=0;//cd be amanat dade shode
p->num-=1;} //yek vahed az mojoudi kam mishavad
}}
void cdbank::ret(){//*****************************************
int code;node *p;
cout<<"code";
cin>>code;
p=first;
while (p){
p=p->next;
if(p->id==code){
p->other=1;
p->num+=1;}}}
void main(){//************************************************** **
cdbank c;
c.enter();
c.del();
c.searcha();
c.searchb();
c.get();
c.ret();
c.show();
getch();}
این پروژه مربوط به یک بانک سی دیه.
کسی میتونه برام درستش کنه؟
enter:کد سی دی را میگیرد و به لیست پیوندی به صورت مرتب اضافه میکند
del:حذف سی دی پس از یافتن آن
searcha:جستجو بر اساس موضوع ونمایش نتیجه آن
searchb:جستجو بر اساس نام سی دی ونمایش آن
get:امانت سی دی و کم کردن یک واحد از موجودی سی دی
ret:برگشت سی دی و اضافه کردن یک واحد به موجودی
show:نمایش تمام گره ها پس از انجام تغییرات
#include "conio.h"
#include "iostream.h"
#include "string.h"
#include "stdio.h"
class node {// ***********************************************
friend class cdbank;
int id;
char name[20];
char subject[20];
int num;
int date;
int other;
char exp[50];
class node* next;};
class cdbank{//********************************************
friend class node;
public:
cdbank();
~cdbank();
void show();
void enter();
void del();
void searcha();
void searchb();
void ret();
void get();
private:
node *first;};//*************************************
cdbank::cdbank(){
first='\0';}
cdbank::~cdbank(){ //**********************************
node *p;
p=first;
while(first!='\0'){
first=p->next;
delete p;
p=first;}}
void cdbank::show(){ //********************************
node *p;
p=first;
while(p){
p=p->next;
cout<<p->id<<p->name<<p->subject<<p->date<<p->other<<p->exp;}}
void cdbank::enter(){//***************************************
node *p,*q,*t;
int n,i;
cout<<"please enter n";
cin>>n;
for(i=0;i<=n;++i){
p=new node;
cout<<"p->id";
cin>>p->id;
if(p->id<1000)
cout<<"error";
else{
cout<<"your id is right";
cout<< "p->name"<<"p->subject"<<"p->date"<<"p->other"<<"p->exp";
cin>>p->id>>p->name>>p->subject>>p->date>>p->other>>p->exp;
p->next='\0';
if(!first)
first=p;
else{
q=first;
while(q&&q->id<p->id){
t=q;
q=q->next;}
if(q==first){
p->next=first;}
else{
p->next=t->next;
t->next=p;
}}}}
void cdbank::del(){ //***************************************
int cnt,j,idd;
node *p,*q;
cout<<"please enter cnt";
cin>>cnt;
for(j=0;j<=cnt;++j){
cout<<"enter idd";
cin>>idd;
p=first;
while(p){
p=p->next;
if(p->id=idd)
if(p=first)
first= p->next;
else
q->next=p->next;}}}
delete p;} //************************************************
void cdbank::searcha(){//namayesh gere ba mozoue morede nazar
node *p;
char s[20];
cout<< "s";
cin>>s;
p=first;
while(p){
p=p->next;
if(strcmp(s,p->subject)== 0)
cout<<p->id<<p->name<<p->subject<<p->date<<p->exp;
else
cout<<"your s not found";}}
void cdbank::searchb(){ //************************************
node *p;
char n[20];
cout<<"n";
cin>>n;
p=first;
while(p){
p=p->next;
if(strcmp(n,p->name)==0)
cout<<p->id<<p->name<<p->subject<<p->date<<p->exp;
else
cout<<"your n not found";}}
void cdbank::get(){ //******************************************
int id;node *p;
cout<<"id";
cin>>id;
p=first;
while (p){
p=p->next;
if(p->id==id){
p->other=0;//cd be amanat dade shode
p->num-=1;} //yek vahed az mojoudi kam mishavad
}}
void cdbank::ret(){//*****************************************
int code;node *p;
cout<<"code";
cin>>code;
p=first;
while (p){
p=p->next;
if(p->id==code){
p->other=1;
p->num+=1;}}}
void main(){//************************************************** **
cdbank c;
c.enter();
c.del();
c.searcha();
c.searchb();
c.get();
c.ret();
c.show();
getch();}