当前位置:网站首页>PTA 1102 教超冠军卷

PTA 1102 教超冠军卷

2022-07-07 16:49:00 邓某人的父亲

1102 教超冠军卷

#include <iostream>
using namespace std;
struct paper
{
    
  string ID;
  int price;
  int Purchases;
  long long int products;
};
int main()
{
    
	int N;
	cin >> N;
	paper p[N];
	for (int i = 0; i < N; i++)
	{
    
		cin >> p[i].ID >> p[i].price >> p[i].Purchases;
		p[i].products = p[i].price * p[i].Purchases;
	}
	paper maxPorchases = p[0];
	paper maxProducts = p[0];
	for (int i = 0; i < N; i++)
	{
    
		if (maxPorchases.Purchases < p[i].Purchases)
			maxPorchases = p[i];
		if (maxProducts.products < p[i].products)
			maxProducts=p[i];
	}
	cout<<maxPorchases.ID<<" "<<maxPorchases.Purchases<<"\n";
	cout<<maxProducts.ID<<" "<<maxProducts.products;
}
原网站

版权声明
本文为[邓某人的父亲]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_62121252/article/details/125637186