#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct T{
string id;
int value;
};//用例
bool compare_texts(const T& a,const T& b){
if(a.value!=b.value){
return a.value > b.value;
}
else{
return a.id < b.id;
}
}
int main() {
int N,M;//n为特性数量,m为用例数量
cin >> N >> M;
vector<int> arr(N+1,0);
for(int i = 1;i <= N;i++){
cin >> arr[i];
}
cin.ignore();
vector<T> texts;
string s;
for(int i = 1;i <= M;i++){
string name = "T" + to_string(i);
getline(cin, s);
istringstream iss(s);
int value = 0;
int index;
while(iss >> index){
value += arr[index];//计算权重
}
texts.push_back({name, value});
}
//排序
sort(texts.begin(),texts.end(),compare_texts);
for(const auto& text : texts){
cout << text.id << endl;
}
}
测试用例执行计划(C++)
最新推荐文章于 2024-08-17 13:49:52 发布
该篇文章描述了一个C++程序,通过定义一个名为T的结构体,包含id和value属性,用于表示具有不同权重的用例。程序读取特性数量和用例数量,计算每个用例的权重,然后根据权重和ID对用例进行排序并输出。
摘要由CSDN通过智能技术生成