Answer to Question #245402 in Java | JSP | JSF for Dillu

Question #245402

review this


problem again. You can use print to


debug your code. The printf) may not work in case of syntax/runtime error. The version of GCC being used is 5.5.0 An e-commerce company wishes to buckettze its products. Each product has a product ID The product ID is a numeric number The company has to find the bucket ID from the product ID. The company needs an algorithm which takes the product ID as an input, calculates the smallest and largest permutation with the digits of the product ID, then outputs the sum of these smallest and largest permutations as the bucket ID


Write an algorithm for the company to find the bucket ID for the given product


Input


The input consists of an integer producti representing the product ID of the product.


Output


Print an integer representing the bucket ID for the given product


Example


1
Expert's answer
2021-10-01T16:52:34-0400
#include <bits/stdc++.h>

using namespace std;

int main() 
{
  int id;
  cin >> id;

  string s = to_string(id);

  sort(s.begin(), s.end());
  int a = stoi(s);

  reverse(s.begin(), s.end());
  int b = stoi(s);

  cout << "id" << a + b << endl;

  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS