From 7ed428fd61f02cb680276d3cadb495148a6ddbdd Mon Sep 17 00:00:00 2001 From: rakesh Date: Thu, 22 Nov 2018 21:10:23 +0530 Subject: [PATCH] link list --- Billing.cpp | 198 +++++++++++++++++++++++++++++++++ item.dat | Bin 0 -> 200 bytes linklist.cpp | 134 ++++++++++++++++++++++ queue_2.cpp | 108 ++++++++++++++++++ queue_linkList.cpp | 117 +++++++++++++++++++ stack_linklist_implemented.cpp | 107 ++++++++++++++++++ website_builder.cpp | 40 +++++++ 7 files changed, 704 insertions(+) create mode 100644 Billing.cpp create mode 100644 item.dat create mode 100644 linklist.cpp create mode 100644 queue_2.cpp create mode 100644 queue_linkList.cpp create mode 100644 stack_linklist_implemented.cpp create mode 100644 website_builder.cpp diff --git a/Billing.cpp b/Billing.cpp new file mode 100644 index 0000000..765898e --- /dev/null +++ b/Billing.cpp @@ -0,0 +1,198 @@ +/* Computer project on retail Billing + made by : rakesh kumar + Last compiled on : 23-10-2018 +*/ +#include +#include +#include +#include +#include +using namespace std; +void line(int n=120, char ch='-'){ + for(int i=0;i>invoice_no; + cout<<"Customer Name :"; + fflush(stdin); + cin.getline(customer_name,30); + cout<<"Phone No:"; + fflush(stdin); + cin.getline(phone_no); + do{ + cout<<"Item No:"; + cin>>titem_no; + name = item_name(titem_no); + cout<<"Name :"<>qty; + amount += price*qty; + cout<<"Total Payable amount :"<>item_no; + cout<<"Item Name :"; + fflush(stdin); + cin.getline(item_name,30); + cout<<"Item Price :"; + fflush(stdin); + cin>>item_price; +} + +void item::show_data(){ + cout<<"Item No :"<>titem_no; + + fin.open("item.dat",ios::in|ios::binary); + fout.open("temp.dat",ios::out|ios::binary); + while(fin.read((char*)this,sizeof(item))) + { + if(item_no!=titem_no) + fout.write((char*)this,sizeof(item)); + } + fin.close(); + fout.close(); + remove("item.dat"); + rename("temp.dat","item.dat"); +} + +void item::edit_item(){ + int titem_no; + ifstream fin; + ofstream fout; + system("cls"); + cout<<"\n\t\t Edit Item Screen\n"; + cout<<"Item No :"; + cin>>titem_no; + + fin.open("item.dat",ios::in|ios::binary); + fout.open("temp.dat",ios::out|ios::binary); + while(fin.read((char*)this,sizeof(item))) + { + if(item_no==titem_no) + read_data(); + fout.write((char*)this,sizeof(item)); + } + fin.close(); + fout.close(); + remove("item.dat"); + rename("temp.dat","item.dat"); +} + +void item::report(){ + ifstream fin; + fin.open("item.dat",ios::in|ios::binary); + system("cls"); + cout<<"\n\t\t\t\t\t\t List of Items\n\n"; + line(); + cout<<"S.NO\t\t\tItem No\t\t\t Item Name \t\t\t Price\n"; + line(); + int i=1; + while(fin.read((char*)this,sizeof(item))) + { + cout<>choice; + switch(choice) + { + case 1: + add_item(); + break; + case 2: + delete_item(); + break; + case 3: + edit_item(); + break; + case 4: + report(); + break; + case 5: + break; + default: + cout<<"\n\n Wrong choice...Try again"; + getch(); + } + }while(choice!=5); +} + +int main(){ + item A; + A.main_menu(); + return 0; +} diff --git a/item.dat b/item.dat new file mode 100644 index 0000000000000000000000000000000000000000..6fc76d40452477091229326fb8832db71cf80ccf GIT binary patch literal 200 zcmYdgU|=Xp%q=J_$^^0)7}UTdf`)KSoKk^|oYD#g{OUNI(tzrU5-ala5+ORVo43O; c11O!5n46djQHIlAkgGiM^HMAEs%vus04UB9t^fc4 literal 0 HcmV?d00001 diff --git a/linklist.cpp b/linklist.cpp new file mode 100644 index 0000000..89f2b4d --- /dev/null +++ b/linklist.cpp @@ -0,0 +1,134 @@ +/* Program to display list list functionality + made by : rakesh kumar +*/ +#include +#include +using namespace std; +struct node{ + int data; + node *ptr; +}; + +class linklist{ + node *x,*y,*temp; + public: + linklist(){ + x=NULL; + } + void add_node_begin(); + void add_node_end(); + void delete_begin(); + void show_data(); +}; + +void linklist::add_node_begin(){ + if(x==NULL) + { + x = new(node); + cout<<"Enter value :"; + cin>>x->data; + x->ptr=NULL; + } + else + { + temp = new(node); + cout<<"Enter value :"; + cin>>temp->data; + temp->ptr=x; + x= temp; + } + return; +} + +void linklist::add_node_end(){ + if(x==NULL) + { + x= new(node); + cout<<"Enter value :"; + cin>>x->data; + x->ptr= NULL; + } + else + { + y = x; + while(y->ptr!=NULL) + y = y->ptr; + y->ptr = new(node); + y = y->ptr; + cout<<"Enter value :"; + cin>>y->data; + y->ptr =NULL; + } + return; +} + +void linklist::delete_begin(){ + if(x==NULL) + { + cout<<"Link list empty"; + getch(); + } + else + { + temp = x; + x= x->ptr; + delete(temp); + } + return; +} + +void linklist::show_data() +{ + if(x==NULL) + { + cout<<"Link list empty"; + getch(); + } + else + { + y = x; + while(y!=NULL) + { + cout<data<<"\t"; + y = y->ptr; + } + getch(); + } + return; +} + +int main(){ + linklist l; + int choice; + + do{ + system("cls"); + cout<<"\n\n\t\t\t LINK LIST MENU"; + cout<<"\n\n\n\t\t1. Add at begining"; + cout<<"\n\n\n\t\t2. Add at end"; + cout<<"\n\n\n\t\t3. Delete from beginging"; + cout<<"\n\n\n\t\t4. Show contents"; + cout<<"\n\n\n\t\t5. Exit"; + cout<<"\n\n\n\n\t\t\t Enter your choice (1..5) :"; + cin>>choice; + switch(choice) + { + case 1: l.add_node_begin(); + break; + case 2: + l.add_node_end(); + break; + case 3: + l.delete_begin(); + break; + case 4: + l.show_data(); + break; + case 5: + break; + default: + cout<<"\n\n Wrong choice...Try again"; + } + }while(choice!=5); + return 0; +} diff --git a/queue_2.cpp b/queue_2.cpp new file mode 100644 index 0000000..519bf3a --- /dev/null +++ b/queue_2.cpp @@ -0,0 +1,108 @@ +/* Program to display list list implemented queue + made by : rakesh kumar +*/ +#include +#include +using namespace std; +struct node{ + int data; + node *ptr; +}; + +class queue{ + node *front,*rear,*temp,*y; + public: + queue(){ + front=rear=NULL; + } + void add_node(); + void delete_node(); + void show_data(); +}; + +void queue::add_node(){ + if(rear==NULL) + { + rear = new(node); + cout<<"Enter value :"; + cin>>rear->data; + rear->ptr=NULL; + front = rear; + } + else + { + rear->ptr = new(node); + rear = rear->ptr; + cout<<"Enter value :"; + cin>>rear->data; + rear->ptr = NULL; + } + return; +} + +void queue::delete_node(){ + if(front==NULL) + { + cout<<"Queue empty"; + getch(); + } + else + { + temp = front; + front = front->ptr; + delete(temp); + } + return; +} + +void queue::show_data() +{ + if(front==NULL) + { + cout<<"Queue empty"; + getch(); + } + else + { + y = front; + while(y!=NULL) + { + cout<data<<"\t"; + y = y->ptr; + } + getch(); + } + return; +} + +int main(){ + queue q; + int choice; + + do{ + system("cls"); + cout<<"\n\n\n\t\t QUEUE MENU"; + cout<<"\n\n\n\t\t1. Add Node"; + cout<<"\n\n\n\t\t2. Delete Node"; + cout<<"\n\n\n\t\t3. Show contents"; + cout<<"\n\n\n\t\t4. Exit"; + cout<<"\n\n\n\n\t\t Enter your choice (1..4) :"; + cin>>choice; + switch(choice) + { + case 1: q.add_node(); + break; + case 2: + q.delete_node(); + break; + case 3: + q.show_data(); + break; + case 4: + break; + default: + cout<<"\n\n Wrong choice...Try again"; + } + }while(choice!=4); + return 0; +} diff --git a/queue_linkList.cpp b/queue_linkList.cpp new file mode 100644 index 0000000..7e91d85 --- /dev/null +++ b/queue_linkList.cpp @@ -0,0 +1,117 @@ +/* Program to display list list implemented queue + made by : rakesh kumar +*/ +#include +#include +using namespace std; +struct node{ + int data; + node *ptr; +}; + +class queue{ + node *front,*rear,*temp,*y; + public: + queue(){ + front=rear=NULL; + } + void add_node(); + void delete_node(); + void show_data(); +}; + +void queue::add_node(){ + if(rear==NULL) + { + rear = new(node); + cout<<"Enter value :"; + cin>>rear->data; + rear->ptr=NULL; + front = rear; + } + else + { + rear->ptr = new(node); + rear = rear->ptr; + cout<<"Enter value :"; + cin>>rear->data; + rear->ptr = NULL; + } + return; +} + +void queue::delete_node(){ + if(front==NULL) + { + cout<<"Queue empty"; + getch(); + } + else + if(front==rear) + { + temp = front; + front = front->ptr; + delete(temp); + rear= front; + } + else + { + temp = front; + front= front->ptr; + delete(temp); + } + + return; +} + +void queue::show_data() +{ + if(front==NULL) + { + cout<<"Queue empty"; + getch(); + } + else + { + y = front; + while(y!=NULL) + { + cout<data<<"\t"; + y = y->ptr; + } + getch(); + } + return; +} + +int main(){ + queue q; + int choice; + + do{ + system("cls"); + cout<<"\n\n\n\t\t QUEUE MENU"; + cout<<"\n\n\n\t\t1. Add Node"; + cout<<"\n\n\n\t\t2. Delete Node"; + cout<<"\n\n\n\t\t3. Show contents"; + cout<<"\n\n\n\t\t4. Exit"; + cout<<"\n\n\n\n\t\t Enter your choice (1..4) :"; + cin>>choice; + switch(choice) + { + case 1: q.add_node(); + break; + case 2: + q.delete_node(); + break; + case 3: + q.show_data(); + break; + case 4: + break; + default: + cout<<"\n\n Wrong choice...Try again"; + } + }while(choice!=4); + return 0; +} diff --git a/stack_linklist_implemented.cpp b/stack_linklist_implemented.cpp new file mode 100644 index 0000000..1148c33 --- /dev/null +++ b/stack_linklist_implemented.cpp @@ -0,0 +1,107 @@ +/* Program to display list list implemented stack + made by : rakesh kumar +*/ +#include +#include +using namespace std; +struct node{ + int data; + node *ptr; +}; + +class stack{ + node *x,*y,*temp; + public: + stack(){ + x=NULL; + } + void push(); + void pop(); + void show_data(); +}; + +void stack::push(){ + if(x==NULL) + { + x = new(node); + cout<<"Enter value :"; + cin>>x->data; + x->ptr=NULL; + } + else + { + temp = new(node); + cout<<"Enter value :"; + cin>>temp->data; + temp->ptr=x; + x= temp; + } + return; +} + +void stack::pop(){ + if(x==NULL) + { + cout<<"Stack empty"; + getch(); + } + else + { + temp = x; + x= x->ptr; + delete(temp); + } + return; +} + +void stack::show_data() +{ + if(x==NULL) + { + cout<<"Stack empty"; + getch(); + } + else + { + y = x; + while(y!=NULL) + { + cout<data<<"\t"; + y = y->ptr; + } + getch(); + } + return; +} + +int main(){ + stack l; + int choice; + + do{ + system("cls"); + cout<<"\n\n\n\t\t STACK MENU"; + cout<<"\n\n\n\t\t1. Push"; + cout<<"\n\n\n\t\t2. POP"; + cout<<"\n\n\n\t\t3. Show contents"; + cout<<"\n\n\n\t\t4. Exit"; + cout<<"\n\n\n\n\t\t Enter your choice (1..4) :"; + cin>>choice; + switch(choice) + { + case 1: l.push(); + break; + case 2: + l.pop(); + break; + case 3: + l.show_data(); + break; + case 4: + break; + default: + cout<<"\n\n Wrong choice...Try again"; + } + }while(choice!=4); + return 0; +} diff --git a/website_builder.cpp b/website_builder.cpp new file mode 100644 index 0000000..7452a19 --- /dev/null +++ b/website_builder.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +using namespace std; +int main(){ + char title[160]; + char heading[180]; + char intro[6000]; + char image[1000]; + + cout<<"\n\n\n\t\t\t\t WebSIte Builder \n"; + cout<<"\n Website Title :"; + fflush(stdin); + cin.getline(title,160); + cout<<"\n Website Heading :"; + fflush(stdin); + cin.getline(heading,180); + cout<<"\n Website Introductory Text :"; + fflush(stdin); + cin.getline(intro,6000); + cout<<"\n Image Path:"; + fflush(stdin); + cin.getline(image,1000); + + ofstream fout; + fout.open("index.html"); + fout<<""; + fout<<""; + fout<<""<<title<<""; + fout<<""; + fout<<""; + fout<<"

"<"; + fout<<""; + fout<<"

"<"; + fout<<""; + fout<<""; + fout.close(); + cout<<"\n Please check your folder ...."; + return 0; +}