problem e. distance
input file: standard input
output file: standard output
time limit: 1 seconds memory limit: 128 megabytes
大家都知道马大佬很皮 马大佬很喜欢住在僻静的街道上,我们把这个街道比作一个数轴,每一个房子都在一个
整数点上,且一个位置上只能有一个房子,在这个街道上有 2 个商店,现在马大佬知道两个 商店的位置,马大佬想问你两个商店之间的距离是多少
例如:第一个商店的位置为 1,第二个商店的位置为 3,则距离为 3-1=2
input
输入第一行一个整数 t,代表接下来有 t 组测试数据
接下来 t 行,每一行输入两个数 a 和 b,分别代表两个商店的位置
1 £ t £ 10000,1 £ n, m £ 10000
output
对于每一组测试数据,输出对应答案
example
standard input |
standard output |
1 1 3 |
2 |
#include<iostream> #include<cmath> using namespace std; int main() { int t; cin >> t; while(t--) { int a,b; cin >> a >> b; cout << abs(a-b) << endl; } return 0; }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/c-cdevelopment/601384.html