forked from jrabhishek/dsa_assignment1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6.c
More file actions
46 lines (40 loc) · 758 Bytes
/
Copy path6.c
File metadata and controls
46 lines (40 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<stdlib.h>
#include<stdio.h>
int main()
{
int n,*array,element,i,j,c;
printf("enter no of elements\n");
scanf("%d",&n);
array = (int*)malloc(n * sizeof(int));
if (array == NULL)
{
return 0;
}
printf("enter elements in array\n");
for( i = 0; i < n; ++i)
{
scanf("%d",array+i);
}
printf("======================================================\n");
printf("ELEMEMTS\tNGC\t\n");
printf("=========================================================\n");
for ( i = 0; i < n-1; ++i)
{
c=0;
for(j=i+1 ;j<n;j++)
{
if (i[array] <j[array])
{
printf("%d\t%d\t\n",i[array],j[array] );
c=1;
break;
}
}
if (c==0)
{
printf("%d\t-1\t\n",i[array] );
}
}
printf("%d\t-1\t\n",(n-1)[array] );
return 0;
}