#include <iostream> using namespace std; int main() { int testCase; //測資數目 int storeNum; //商店的數量 cin>>testCase; while (testCase--) { int minNumber = 9999; //最小值 int maxNumber = 0; //最大值 int number; //商店號碼 cin>>storeNum; for (int i = 0; i < storeNum; i++) { cin>>number; if (number > maxNumber) { maxNumber = number; } if (number < minNumber) { minNumber = number; } } cout << (maxNumber - minNumber)*2; } return 0; }UVA題目網址http://bit.ly/2miHPEJ
沒有留言:
張貼留言