You are on page 1of 2

#include<stdio.h> #include<stdlib.h> #include<malloc.

h> struct node { int info; //arr time=info int bt; struct node *next; }*start,*ptr,*r,*q; void create(int a,int b) { if(start==NULL) { start=(struct node*)malloc(sizeof(struct node)); start->info=a; start->bt=b; start->next=NULL; ptr=start; } else { ptr->next=(struct node*)malloc(sizeof(struct node)); ptr=ptr->next; ptr->info=a; ptr->bt=b; ptr->next=NULL; } } void sort() { int temp,temp2; struct node *r; r=start; int c=0,i=0; while(r->next!=NULL) { c++;r=r->next; } for(i=0;i<c;i++) { r=start; q=start->next; while(q!=NULL) { if(r->info>q->info) { temp=r->info; r->info=q->info; q->info=temp; temp2=r->bt; r->bt=q->bt; q->bt=temp2; } r=r->next;

q=q->next; } } } int main() { int ch=1; while(ch==1) { int att,btt; printf("enter the arrival time and and burst time"); scanf("%d %d ",&att,&btt); create(att,btt); printf("enter 1 to create more"); scanf("%d",&ch); } sort(); ptr=start; while(ptr->next!=NULL) { printf("arrival time burst time\n"); printf("%d %d",ptr->info,ptr->bt); ptr=ptr->next; } return 0; }

You might also like