⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 中山大学ACM SICILY 1093 air express题目代码
💻 CPP
字号:
#include<iostream>
using namespace std;
#include<stdio.h>

int main()
{
	int a[1002];
	int w1,w2,w3,r1,r2,r3,r4;
	while(1)
	{
		cin>>w1>>r1>>w2>>r2>>w3>>r3>>r4;
		int i=0;

		do
		{
			scanf("%d",&a[i]);
			if(a[i]<=0) break;
			else i++;
		}while(1);
		if(a[0]<=0) break;

		for(int k=0;k<i;k++)
		{
			if((a[k]>0)&&(a[k]<=w1))
			{
				if(a[k]*r1>(w1+1)*r2)
				{
					int s=w1+1-a[k];
					cout<<"Weight ("<<a[k]<<") has best price $"<<(w1+1)*r2<<" (add "<<s<<" pounds)"<<endl;
				}
				else cout<<"Weight ("<<a[k]<<") has best price $"<<a[k]*r1<<" (add 0 pounds)"<<endl;
			}
		

			else if((a[k]>=(w1+1))&&(a[k]<=w2))
			{
				if(a[k]*r2>(w2+1)*r3)
				{
					int t=w2+1-a[k];
					cout<<"Weight ("<<a[k]<<") has best price $"<<(w2+1)*r3<<" (add "<<t<<" pounds)"<<endl;
				}
				else cout<<"Weight ("<<a[k]<<") has best price $"<<a[k]*r2<<" (add 0 pounds)"<<endl;
			}

			else 	if((a[k]>=(w2+1))&&(a[k]<=w3))
			{
				if(a[k]*r3>(w3+1)*r4)
				{
					int u=w3+1-a[k];
					cout<<"Weight ("<<a[k]<<") has best price $"<<(w3+1)*r4<<" (add "<<u<<" pounds)"<<endl;
				}
				else cout<<"Weight ("<<a[k]<<") has best price $"<<a[k]*r3<<" (add 0 pounds)"<<endl;	
			}

			else if(a[k]>=(w3+1)) cout<<"Weight ("<<a[k]<<") has best price $"<<a[k]*r4<<" (add 0 pounds)"<<endl;	
		}
		cout<<endl;
	}

   
        cin.get();
        cin.get();
		return 0;
	
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -