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; }
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/96295.html
標籤:C++
