视频讲解:
求最值 代码
#include#include using namespace std; int main() { int n; cin >> n; string id; int price, count; string bestId, bestId2; int bestCount = -1; int bestTotal = -1; for(int i = 0; i < n; i++) { cin >> id >> price >> count; if(count > bestCount) { bestCount = count; bestId = id; } if(price*count > bestTotal){ bestTotal = price*count; bestId2 = id; } } cout< 欢迎分享,转载请注明来源:内存溢出
评论列表(0条)