当前位置:网站首页>PTA 1102 teaching Super Champion volume

PTA 1102 teaching Super Champion volume

2022-07-07 18:56:00 Deng sb's father

1102 Teach Super Champion

#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;
}
原网站

版权声明
本文为[Deng sb's father]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071649412484.html