4998: a+b+c+d=?

4998: a+b+c+d=?

Description

This is a very simple problem! Your only job is to calculate a + b + c + d!

Input

There are several cases.
In the first line, there is a single integer T.(T <= 200)
In the next T lines, each line contains four integers a, b, c and d(-2^61 <= a,b,c,d <=2^61)

Output

output T lines.
Each line output one integer represent the answer of a + b + c + d

Sample Input

1
1 2 3 4

Sample Output

10

思路

实际上很简单,就是将四个数加起来就行了
a+b+c+d,并用repeat来决定需要输入的数据组数

细节

很多人再交上去的时候都会出现过不了的情况,为什么呢?
大家需要注意的是a,b,c,d的取值范围是(-2^61 <= a,b,c,d <=2^61)
有些人会说那我把它们都定义为long long不就够了吗
long long最大不就是 2^63 嘛,刚好四个数4 * 2^61= 2^63
但值得注意的是, 2^63是恰好取不到的数,所以我们应该用一个更大的类型来定义,这里给大家介绍一个long double它比long long还要长
long long是占了8个字节而long double占了12个字节
long double是用 %Lf 进行输出

展示代码

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long double a,b,c,d,sum;
	int repeat,t;
	while(scanf("%d",&repeat)!=EOF)    //持续输入
	{
		for(t=0;t<repeat;t++)
	{
		scanf("%Lf%Lf%Lf%Lf",&a,&b,&c,&d);
		sum=a+b+c+d;
		printf("%.0Lf\n",sum);      //保留0位小数
	}
	}
	return 0;
 } 

结尾

希望对大家有帮助!!!
有问题可在下面留言,谢谢…
哈哈,还是一样…
本人刚开始学没多久,并且心理承受能力不太行,如有错误或更好的方法请好好说,千万别骂我,拜托拜托😅🙏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Min-篮球小菜鸡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值