-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_026.c
30 lines (24 loc) · 818 Bytes
/
Day_026.c
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
#include<stdio.h>
#include<stdlib.h>
int main()
{
int row,col,noOfGroups,currentValue = 1;
scanf("%d %d %d",&row,&col,&noOfGroups);
int groups[noOfGroups],output[row][col];
for(int counter=0;counter<noOfGroups;counter++)
scanf("%d",&groups[counter]);
for(int rowCounter=row-1;rowCounter>=0;rowCounter--)
for(int colCounter=0;colCounter<col;colCounter++)
{
if(groups[currentValue-1]==0)
currentValue++;
groups[currentValue-1]--;
output[rowCounter][colCounter]=currentValue;
}
for(int rowCounter=0;rowCounter<row;rowCounter++)
{
for(int colCounter=0;colCounter<col;colCounter++)
printf("%d ",output[rowCounter][colCounter]);
printf("\n");
}
}