forked from jrabhishek/dsa_assignment1
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11.c
More file actions
48 lines (41 loc) · 637 Bytes
/
Copy path11.c
File metadata and controls
48 lines (41 loc) · 637 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
47
48
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *array,i,n,c,j;
printf("enter size of array\n");
scanf("%d",&n);
array = (int*)malloc(n * sizeof(int));
printf("enter elements of array\n");
for ( i = 0; i < n; ++i)
{
scanf("%d",(array+i));
/* code */
}
for ( i = 0; i < n-1; ++i)
{
c = 0;
for ( j = i+1; j < n; ++j)
{
if (*(array+j)> *(array+i))
{
/* code */
i[array] = j[array];
c= 1;
break;
}
/* code */
}
if (c==0)
{
i[array] = -1;
}
/* code */
}
*(array+n-1) = -1;
printf("resulted array\n");
for ( i = 0; i < n; ++i)
{
printf("%d\n",*(array+i));
}
}