爱奇艺编程题:数字游戏

题目:https://www.nowcoder.com/practice/4f356b0618d14737a6f3782771bb4079?tpId=90&tqId=30798&rp=2&ru=/ta/2018test&qru=/ta/2018test/question-ranking

#include

using namespace std;

void func(int &x){

string s = to_string(x);

sort(s.begin(),s.end(),less());

int i = 0;

while(s[i] == '0')

++i;

x = stoi(s.substr(i));

}

int main()

{

int n;

cin >> n;

vector num(n);

for(auto i = 0;i < n;++i)

cin>>num[i];

for_each(num.begin(),num.end(),func);

auto pos = max_element(num.begin(),num.end());

cout<<*pos<

    return 0;

}

你可能感兴趣的:(爱奇艺编程题:数字游戏)