#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int n, min;
cin >> n;
for (int i = 0; i < n; i++) {
string str;
cin >> str;
sort(str.begin(), str.end());
min = atoi(str.c_str());
sort(str.rbegin(), str.rend());
cout << atoi(str.c_str()) - min << endl;
}
return 0;
}
ショートコーディングすると,241byteでC++の中では一番短いみたいですが,
Cで書かれた一番短いコードとは100byte近く離されてる・・・。
0 件のコメント:
コメントを投稿