洛谷-广告计划-野题

题目描述 Description

公司最近生产出一种新产品,正准备上市销售,广告部也准备了相应的宣传
广告以增加销售量。现在已知新产品有宣传广告和无宣传广告的预期收入以及广
告的费用,请你编程来决定是否需要使用广告来宣传这个新产品。

输入输出格式 Input/output

输入格式:
第一行为 t1<=t<=10000 ),表示测试数据组数。
接下来 t行,每行三个数字 r,e和 c,分别表示新产品无宣传广告的预期收
入、有宣传广告的预期收入以及宣传广告的费用(-10^6<=r,e<=10^6,0<=c<=10^6)
输出格式:
对于每个输入数据,输出一行字符串:如果宣传广告后收入增加,则输出
“profit”;如果宣传广告后收入降低,则输出“deficit”,如果宣传广告后,
收支平衡,则输出“balance”
输入输出样例 Sample input/output
样例测试点#1
输入样例:

3

0 100 70

100 130 30

-100 -70 40

输出样例:

profit

balance

deficit

思路:用(有广告收入-广告费)和无广告收入比较就可以了。。。

代码如下:

 1 #include <stdio.h>
 2 int main()
 3 {
 4     int n,i;
 5     int r,e,c;
 6     //freopen("advertise.in","r",stdin);
 7     //freopen("advertise.out","w",stdout);    
 8     scanf("%d",&n);
 9     while(n>0)
10     {
11         n--;
12         scanf("%d%d%d",&r,&e,&c);
13         if(r>(e-c)) printf("deficit
");
14         else if(r==(e-c)) printf("balance
");
15         else printf("profit
");
16     }
17     return 0;
18 }
原文地址:https://www.cnblogs.com/geek-007/p/4648954.html