⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1497.cpp

📁 杭电 acm部分代码 有兴趣的可以下载 谢谢
💻 CPP
字号:
#include<stdio.h>
#include<iostream>
using namespace std;
long book[100001],num[1001];
long m,n;
void B()
{
    long u, b;
    scanf("%ld %ld", &u, &b);
    if(book[b] != 0)
    {
        printf("The book is not in the library now\n");
    }
    else
    {
        if(num[u] >= 9)
        {
            printf("You are not allowed to borrow any more\n");
        }
        else
        {
            num[u]++;
            book[b] = u;
            printf("Borrow success\n");
        }
    }
}
void R()
{
    long b;
    scanf("%ld", &b);
    if(book[b] == 0)
    {
        printf("The book is already in the library\n");
    }
    else
    {
        num[book[b]]--;
        book[b] = 0;
        printf("Return success\n");
    }
}
void Q()
{
    long u;
    scanf("%ld", &u);
    if(num[u] == 0)
    {
        printf("Empty\n");
    }
    else
    {
        long i = 0, j;
        for(j = 1; j <= n; j++)
        {
            if(book[j] == u)
            {
                i++;
                printf("%ld",j);;
                if(i != num[u])
                {
                    printf(" ");
                }
                else
                {
                    printf("\n");
                    return;
                }
            }
        }
    }
}
long main()
{
    long i, tst;
    char cmd;
    while(scanf("%ld %ld", &m, &n) == 2)
    {
        for(i = 1; i <= n; i++)
        {
            book[i] = 0;
        }
        for(i = 1; i <= m; i++)
        {
            num[i] = 0;
        }
        scanf("%ld", &tst);
        while(tst--)
        {
            scanf("\n%c", &cmd);
            if(cmd == 'R')
            {
                R();
            }
            else if(cmd == 'B')
            {
                B();
            }
            else if(cmd == 'Q')
            {
                Q();
            }
        }
        printf("\n");
    }
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -