diff --git a/sort.c b/sort.c new file mode 100644 index 0000000000..e3190f0c84 --- /dev/null +++ b/sort.c @@ -0,0 +1,53 @@ +#include +#include +struct Node +{ + int data; + struct Node *next; +}*first=NULL,*second=NULL,*third=NULL; +void Display(struct Node *p) +{ + while(p!=NULL) + { + printf("%d ",p->data); + p=p->next; + } +} +void create(int A[],int n) +{ + int i; + struct Node *t,*last; + first=(struct Node *)malloc(sizeof(struct Node)); + first->data=A[0]; + first->next=NULL; + last=first; + + for(i=1;idata=A[i]; + t->next=NULL; + last->next=t; + last=t; + } +} +int isSorted(struct Node *p) +{ + int x=-65536; + while(p!=NULL) + { + if(p->data < x) + return 0; + x=p->data; + p=p->next; + } + return 1; +} +int main() +{ + int A[]={10,60,20,30,40,50}; + create(A,5); + printf("%d\n",isSorted(first)); + Display(first); + return 0; +}