Untitled
#include <stdio.h> #define mf 20 #define mb 20 void main() { int n, i, j, x; int b[mf], sb[mf], t[mf]; int c[mf][mb]; printf("Enter number of files (up to %d): ", mf); scanf("%d", &n); for (i = 0; i < n; i++) { printf("Enter number of blocks occupied by file %d: ", i + 1); scanf("%d", &b[i]); printf("Enter the starting block of file %d: ", i + 1); scanf("%d", &sb[i]); t[i] = sb[i]; for (j = 0; j < b[i]; j++) { c[i][j] = sb[i]++; } } printf("Filename\tStart block\tLength\n"); for (i = 0; i < n; i++) { printf("%d\t\t%d\t\t%d\n", i + 1, t[i], b[i]); } printf("Enter file number: "); scanf("%d", &x); printf("File number is: %d\n", x); printf("Length is: %d\n", b[x - 1]); printf("Blocks occupied: "); for (i = 0; i < b[x - 1]; i++) { printf("%4d", c[x - 1][i]); } printf("\n"); }
Leave a Comment