Skip to content

Instantly share code, notes, and snippets.

@LW-Ho
Created November 23, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LW-Ho/a31d1814f1c15dbc3d07 to your computer and use it in GitHub Desktop.
Save LW-Ho/a31d1814f1c15dbc3d07 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i,j;
int SIZE1,SIZE2;
printf("How many ROW ? \n");
scanf("%d",&SIZE1);
//printf("\n");
printf("How many COLUMN ?\n");
scanf("%d",&SIZE2);
//printf("\n");
int allocation[SIZE1][SIZE2];
int max[SIZE1][SIZE2];
int available[SIZE2];
int need[SIZE1][SIZE2];
int result[SIZE1][SIZE2];
/* Here is Allocation */
for (j=0; j<SIZE1 ;j++){
for (i=0 ; i <SIZE2 ;i++){
printf("The Allocation table data %d ROW , %d COLUMN \n",j+1,i+1); //Input Allocation data
scanf("%d",&allocation[j][i]);
printf("\n");
}
}
printf("This is Allocation Array\n");
for (j=0; j<SIZE1 ; j++) {
printf("p%d ",j);
for (i=0 ;i<SIZE2 ; i++) {
printf("%3d ",allocation[j][i]); //Output Allocation Array
}
printf("\n");
}
/*Over Allocation*/
/* Start Max */
for (j=0; j<SIZE1 ;j++) {
for (i=0; i<SIZE2 ;i++) {
printf("The Max table Data %d ROW , %d COLUMN \n",j+1,i+1); //Input Max data
scanf("%d",&max[j][i]);
}
}
printf("This is Max Array \n");
for (j=0; j<SIZE1 ;j++) {
printf("p%d ",j);
for (i=0; i<SIZE2 ;i++) {
printf("%3d ",max[j][i]); //Output Max Array
}
printf("\n");
}
/* Over Max */
/* Start Available */
for (i=0 ;i<SIZE2 ;i++) {
printf("The Available table data %d COLUMN \n",i+1); //Input Available data
scanf("%d",&available[i]);
}
printf("This is Available Array \n");
for (i=0 ;i<SIZE2 ; i++) {
printf("%3d ",available[i]); //Output Available Array
}
printf("\n");
/* Over Available */
/* Need = Max - Allocation */
for (j=0; j<SIZE1 ;j++) {
for (i=0; i<SIZE2 ;i++) {
need[j][i] = max[j][i] - allocation[j][i];
}
}
/* Start Need table */
printf("This is Need Array \n");
for (j=0 ;j<SIZE1 ;j++){
printf("p%d ",j);
for (i=0 ; i<SIZE2 ;i++) {
printf("%3d ",need[j][i]); //output Need data
}
printf("\n");
}
/* Over Need table */
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment