浙大PAT甲级-1022

关键点:

(1)cin输入并没有将换行符输入所以后面如果紧接着getline(cin,str)需先输入完换行符

(2)ID打印注意前面补零(%07d)(否则后面两个测试点过不去)

#include 
#include 
#include 
#include 
#include 
using namespace std;


struct book{
    int id;
    string title;
    string author;
    vector keywords;
    string publisher;
    int year;
};

int N, M;
vector lib;
vector comm;

bool cmp(book b1,book b2){
    return b1.id>N;
    for(i=0;i>b.id;
        string s,words;
        getline(cin,s);//消除ID行结尾的换行符
        getline(cin,b.title);
        getline(cin,b.author);
        getline(cin,words);
        getline(cin,b.publisher);
        cin>>b.year;
        int l=0;
        int cnt=0;
        for(int j=0;j>M;
    string s;
    getline(cin,s);
    for(i=0;i

你可能感兴趣的:(浙大PAT甲级练习题)