• + 0 comments

    Just wanted to share this cause I found this easier

    include

    include

    int main() { int shelfbook[100][100], count=0, count2=0; int total_number_of_shelves; scanf("%d", &total_number_of_shelves);

    int total_number_of_queries;
    scanf("%d", &total_number_of_queries);
    
    while (total_number_of_queries>0)
    {   
        total_number_of_queries--;
        int type_of_query;
        scanf("%d", &type_of_query);
    
        if (type_of_query == 1) 
        {
            int x, y; 
    
            for(count; count>0; count--)
            { shelfbook[x][count]=shelfbook[x][count-1];}
    
            scanf("%d %d", &x, &y);
            shelfbook[x][0]= y;
    
            count++;
    
        } 
        else if (type_of_query == 2) 
        {
            int x, y;
            scanf("%d %d", &x, &y);
            printf("%d",shelfbook[x][y]);
        } 
        else if (type_of_query == 3)
        {
            int x;
            scanf("%d", &x);
    
    
            for (int y=0; y<100; y++)
            {
                if (shelfbook[x][y]!=0)
                { count2++;}
            }
            printf("%d\n", count2);
        }
    }
    
    return 0;
    

    }