SHARE
TWEET

Untitled

a guest Jan 27th, 2020 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Node{
  5.  int data;
  6.  Node *link;
  7. };
  8. Node *head=NULL;
  9.  
  10. void insertEnd (int d)
  11. {
  12.   Node *ptr = new Node();
  13.   ptr->data=d;
  14.   ptr->link=NULL;
  15.  
  16.  
  17.   if(head==NULL)
  18.   head=ptr;
  19.  
  20.   else
  21.   {
  22.    Node *temp = head;
  23.    while(temp->link != NULL)
  24.    {
  25.     temp=temp->link;
  26.    }
  27.    temp->link=ptr;
  28.  
  29.   }
  30.  
  31. }
  32.  
  33. void insertFacNumberAndShoe(int facShoe){
  34.  
  35. while(facShoe){
  36.     insertEnd(facShoe%10);
  37.     facShoe/=10;
  38.  
  39. }
  40.  
  41. }
  42.  
  43. void sortAsc(){
  44.  
  45.  
  46.  Node *current = head;
  47.  while(current->link!=NULL){
  48.  Node *n = current->link;
  49.  Node *indexrazmqna = n;
  50.     int tmp = n->data;
  51.  while(n->link!=NULL){
  52.  if(n->data<tmp){
  53.  tmp = n->data;
  54.  indexrazmqna = n;
  55.  
  56.  }
  57.  n = n->link;
  58.  }
  59.  if(tmp<current->data){
  60.  indexrazmqna->data = current->data;
  61.  current->data = tmp;
  62.  }
  63.  current = current->link;
  64.  }
  65.  
  66.  
  67. }
  68.  
  69.  
  70.  
  71. void dispLink()
  72. {
  73.  Node *temp=head;
  74.  while(temp!=NULL)
  75.  {
  76.   cout<<temp->data<<" ";
  77.   temp=temp->link;
  78.  }
  79.  cout<<"\n";
  80. }
  81.  
  82. int main()
  83. {
  84.  insertFacNumberAndShoe(9201043);
  85.  sortAsc();
  86.  dispLink();
  87.  
  88.  return 0;
  89. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top