Powered By Blogger

Monday, May 4, 2009

C Programming

#include
#include
int a[100];
void merge(int f,int m,int l);
void merge_sort(int f,int l)
{
int m;
if(f<=m&&j<=l) { if(a[h]<=a[j]) { b[i]=a[h]; h=h+1; } else { b[i]=a[j]; j++; } i=i+1; } if(h>m)
{
for(k=j;k<=l;k++)
{
b[i]=a[k];i=i+1;
}
}
else
{
for(k=h;k<=m;k++)
{
b[i]=a[k];i=i+1;
}

}
for(k=f;k<=l;k++)
a[k]=b[k];
}
void main()
{
clrscr();
int f,l,m,i=0,b=0;
printf("Enter element:");
while(b!=-1)
{
scanf("%d",&b);
a[i]=b;
i++;

}
f=0,l=i-2;
merge_sort(f,l);
for(int t=0;t<=i-2;t++)
printf("%d ",a[t]);

getch();
}

0 comments:

About This Blog

This is an important blog about updated news about computer science and technology.

Blog Archive

Visitors

  © Free Blogger Templates Blogger Theme II by Ourblogtemplates.com 2008

Back to TOP