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
#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;
}
Comments
Leave a comment