Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int i;
- int current_total_book; /* holds the size of total book */
- int total_number_of_shelves;
- scanf("%d", &total_number_of_shelves);
- int total_number_of_queries;
- scanf("%d", &total_number_of_queries);
- /* initial size of total book */
- current_total_book = 110;
- /* initializing the dynamic arrays */
- total_number_of_pages = malloc( total_number_of_shelves * sizeof(int*) );
- total_number_of_books = malloc( total_number_of_shelves * sizeof(int) );
- for( i = 0; i < total_number_of_shelves; i++ ){
- total_number_of_books[i] = 0;
- }
- 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 x, y;
- scanf("%d %d", &x, &y);
- int nb;
- total_number_of_books[x]++;
- nb = total_number_of_books[x];
- total_number_of_pages[x] = realloc( total_number_of_pages[x], nb * sizeof( int ) );
- /* put the number of pages y into a shelf x,
- * while also increasing the total number of books in shelf x
- */
- total_number_of_pages[x][nb - 1] = y;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement