Tweet
#include<stdio.h>
main()
{
int i,j,k,n;
printf("Enter array capacity : \n");
scanf("%d",&n);
int a[n];
FILE *fp;
fp=fopen("mat","r");
for(i=0;i<n;i++)
fscanf(fp,"%d",&a[i]);
fclose(fp);
printf("GIVEN ARRAY : ");
for(i=0;i<n;i++)
printf("%4d",a[i]);
for(i=0;i<n;i++)
{ for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
for(k=j;k<n;k++)
a[k]=a[k+1];
j--;
n--;
}
}
}
printf("\nOUTPUT : ");
for(i=0;i<n;i++)
printf("%4d",a[i]);
printf("\n");
}
Delete duplicate elements from array
Posted by
LAHAUL SETH
~
Delete duplicate elements from array
2011-11-29T10:37:00+05:30
LAHAUL SETH
Programming in C
|
Comments
Delete duplicate elements from array
2011-11-29T10:37:00+05:30
LAHAUL SETH
Programming in C
|