xxxxxxxxxx
#include<iostream>
using namespace std;
class node{
public:
int data;
node *next;
void insertData();
void printData();
void sorting();
};
node* head=0;
void node::insertData(){
int c=1;
head=new node();
cout<<"Enter data : ";
cin>>head->data;
head->next=NULL;
node *temp;
temp=head;
node *newnode;
cout<<"Do you want to link another list if yes press 1 else press 2 : ";
cin>>c;
while(c==1)
{
newnode=new node();
cout<<"Enter data : ";
cin>>newnode->data;
newnode->next=NULL;
temp->next=newnode;
temp=temp->next;
cout<<"Do you want to link another list if yes press 1 else press 2 : ";
cin>>c;
}
}
void node::sorting()
{
node* temp;
temp=head;
node* newnode;
int tmp;
while(temp!=NULL)
{
newnode=temp->next;
while(newnode!=NULL)
{
if(temp->data>newnode->data)
{
tmp=temp->data;
temp->data=newnode->data;
newnode->data=tmp;
}
newnode=newnode->next;
}
temp=temp->next;
}
}
void node::printData()
{
node* temp;
temp=head;
while(temp!=0)
{
cout<<temp->data<<" ";
temp=temp->next;
}
}
int main()
{
node *obj;
obj->insertData();
cout<<"\n\nBefore Sorting ......\n\n";
obj->printData();
obj->sorting();
cout<<"\n\nAfter sorting........\n\n";
obj->printData();
return 0;
}
xxxxxxxxxx
#include<iostream.h>
#include<conio.h>
#include<graphic.h>
#include<math.h>
void main()
{clrscr();
int g=0,a;
initgraph(&g,&d,"");
setbkcolor(14);
setcolor(6);
settextstyle(2,0,4);
outtextxy(180,130,"G");
setcolor(5);
settextstyle(2,0,4);
outtextxy(120,120,"O");
setcolor(6);
settextstyle(2,0,4);
outtextxy(300,120,"O");
setcolor(5);
settextstyle(2,0,4);
outtextxy(250,130,"G");
setcolor(2);
settextstyle(2,0,4);
outtextxy(360,160,"L");
setcolor(3);
settextstyle(2,0,4);
outtextxy(310,130,"E");
setcolor(9);
settextstyle(2,0,4);
setcolor(8);
settextstyle(2,0,4);
outtextxy(110,250,"surf");
settextstyle(2,0,4);
outtextxy(350,320,"Go AHEAD");
setcolor(6);
rectangle(130,210,450,210);
rectangle(90,310,170,340);
rectangle(360,320,510,320);
getch();
}