We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int main()
{
int total_number_of_shelves;
scanf("%d", &total_number_of_shelves);
int total_number_of_queries;
scanf("%d", &total_number_of_queries);
total_number_of_books=(int *)calloc(total_number_of_shelves,sizeof(int));
total_number_of_pages=(int **)calloc(total_number_of_shelves,sizeof(int *));
for (int i = 0; i < total_number_of_shelves; i++) {
total_number_of_pages[i] = calloc(1100, sizeof(int));
}
while (total_number_of_queries--) {
int type_of_query;
scanf("%d", &type_of_query);
if (type_of_query == 1) {
/*
* Process the query of first type here.
*/
int shelf, pages;
scanf("%d %d", &shelf, &pages);
total_number_of_books[shelf]++;
int *book = total_number_of_pages[shelf];
while (*book != 0)
book++;
*book = pages;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Dynamic Array in C
You are viewing a single comment's thread. Return to all comments →
int main() { int total_number_of_shelves; scanf("%d", &total_number_of_shelves);