UVa 10055 - Hashmat the Brave Warrior
解题思路:求两个数差值的绝对值,注意用long;
1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 long a,b; 7 while(cin>>a>>b) 8 { 9 if(b>a) 10 cout<<b-a<<endl; 11 else 12 cout<<a-b<<endl; 13 } 14 return 0; 15 }
有多自律,才能有多自由
解题思路:求两个数差值的绝对值,注意用long;
1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 long a,b; 7 while(cin>>a>>b) 8 { 9 if(b>a) 10 cout<<b-a<<endl; 11 else 12 cout<<a-b<<endl; 13 } 14 return 0; 15 }