-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked.c
More file actions
48 lines (45 loc) · 749 Bytes
/
linked.c
File metadata and controls
48 lines (45 loc) · 749 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<stdio.h>
#include<stdlib.h>
int main()
{
int f[50],i,c,k,j,p,n,len,a,st;
for(i=0;i<50;i++)
{
f[i]=0;
}
printf("enter how many blocks are already allocated\n");
scanf("%d",&p);
if(p!=0)
{
printf("enter the block numbers that are already allocated\n");
for(i=0;i<p;i++)
{
scanf("%d",&a);
f[a]=1;
}
X:
printf("enter the starting index block and length");
scanf("%d%d",&st,&len);
k=len;
for(j=st;j<(k+st);j++)
{
if(f[j]==0)
{
f[j]=1;
printf("\n%d->%d",j,f[j]);
}
else
{
printf("\n %d-> file is already allocated\n",j);
k++;
}
}
printf("do you want to enter more file? yes-1 & no-0\n");
scanf("%d",&c);
if(c==1)
goto X;
else
exit(0);
}
return 0;
}