两个数的差

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;
}

猜你喜欢

转载自www.cnblogs.com/biaobiao88/p/11668050.html
今日推荐