#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <iomanip>
using namespace std;
static const char c_zero = '0';
int main(int argc, char** argv){
string str_min, str_max;
double d_min, d_max;
while(cin>>str_min){
while(!str_min.empty() && *(str_min.begin()) == c_zero)
str_min.erase(str_min.begin());
sort(str_min.begin(), str_min.end());
str_max = str_min;
reverse(str_max.begin(), str_max.end());
if(*(str_min.begin()) == c_zero){
int i = str_min.find_first_not_of("0", 0);
iter_swap(str_min.begin(), str_min.begin() + i);
}
istringstream(str_max)>>d_max;
istringstream(str_min)>>d_min;
cout<<fixed<<setprecision(0)<<d_max<<" - "<<d_min<<" = "<<d_max - d_min<<" = 9 * "<<(d_max - d_min)/9<<endl;
}
return 0;
}
UVA 11371
最新推荐文章于 2022-02-25 19:38:17 发布