// PATn.cpp : 定義控制臺應用程序的入口點。
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
class Question
{
public:
Question() = delete;
Question(unsigned &g, unsigned &c, unsigned &r, vector<char> &o) :grade(g), choice_number(c), right_number(r), options(o) {};
unsigned get_grade(vector<char> &s)
{
if (s == options)
return grade;
else
{
wrong += 1;
return 0;
}
}
unsigned get_wrong_count() const
{
return wrong;
}
private:
unsigned grade = 0;
unsigned choice_number = 0;
unsigned right_number = 0;
vector<char> options;
unsigned wrong = 0;
};
int main()
{
unsigned n, m;
cin >> n >> m;
vector<Question> data;
for (unsigned i = 0; i < m; ++i)
{
unsigned t1, t2, t3;
cin >> t1 >> t2 >> t3;
vector<char> tmp;
char chr;
for (unsigned j = 0; j < t3; ++j)
{
cin >> chr;
tmp.push_back(chr);
}
data.push_back(Question(t1, t2, t3, tmp));
}
cin.ignore();
for (unsigned i = 0; i < n; ++i)
{
string stu;
getline(cin,stu);
unsigned total_grade = 0;
unsigned question_id = 0;
unsigned the_first_number = 1;
unsigned the_first_char = 3;
for (unsigned j = 0; j < m; ++j)
{
vector<char> answer;
int k = stoi(string(1, stu[the_first_number]));
for (int h = 0; h < k; ++h)
{
answer.push_back(stu[the_first_char]);
the_first_char += 2;
}
total_grade += data[question_id].get_grade(answer);
question_id += 1;
the_first_number = the_first_char +2;
the_first_char += (6 - 2);
}
cout << total_grade<<endl;
}
unsigned max_wrong = 0;
for (auto &r : data)
{
if (r.get_wrong_count() > max_wrong)
{
max_wrong = r.get_wrong_count();
}
}
if (max_wrong == 0)
cout << "Too simple";
else
{
cout << max_wrong<<" ";
unsigned tmp = 0;
for (auto &r : data)
{
if (r.get_wrong_count() == max_wrong)
{
++tmp;
}
}
for (unsigned j = 0; j<data.size(); ++j)
{
auto &r = data[j];
if (r.get_wrong_count() == max_wrong)
{
cout << (j + 1);
--tmp;
if (tmp != 0) //如果輸出對象,才判斷是否輸出后置空格符?。▽κ褂幂斎胄蛱柕臄祿仪杏洸豢蓅ort(data)改變對象位置!)
cout << " ";
}
}
}
system("pause");
return 0;
}
1058
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
推薦閱讀更多精彩內容
- 今天讀了一遍易仁永澄的博客《別告訴我你懂時間管理》,從本質上搞清楚了時間管理是怎么回事。 以下用圣誕樹模型做一個小...