- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C++ program to find maximum possible amount of allowance after playing the game

Suppose we have three numbers A, B and C. Consider a game: There are three "integer panels", each with a digit form 1 to 9 (both inclusive) printed on it, and one "operator panel" with a '+' sign printed on it. The player should make a formula of the form X+Y, by arranging the four panels from left to right. Then, the amount of the allowance will be equal to the resulting value of the formula.

We have to find the maximum possible amount of the allowance.

So, if the input is like A = 1; B = 5; C = 2, then the output will be 53, because the panels are arranged like 52+1, and this is the maximum possible amount.

## Steps

To solve this, we will follow these steps −

Define an array V with A, B and C sort the array V ans := (V[2] * 10) + V[1] + V[0] return ans

## Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h> using namespace std; int solve(int A, int B, int C){ vector<int> V = { A, B, C }; sort(V.begin(), V.end()); int ans = (V[2] * 10) + V[1] + V[0]; return ans; } int main(){ int A = 1; int B = 5; int C = 2; cout << solve(A, B, C) << endl; }

## Input

1, 5, 2

## Output

53

- Related Questions & Answers
- Program to find minimum possible maximum value after k operations in python
- C++ Program to find maximum score of bit removal game
- C++ program to find winner of typing game after delay timing
- Program to find maximum score of brick removal game in Python
- Program to find the formatted amount of cents of given amount in Python
- C++ program to find maximum possible value of XORed sum
- Program to find maximum possible population of all the cities in python
- Program to find maximum score in stone game in Python
- Find amount of water wasted after filling the tank in C++
- Program to find number of possible moves to start the game to win by the starter in Python
- Program to find maximum possible value of smallest group in Python
- Program to find out the maximum points collectable in a game in Python
- C++ Program to find array after removal from maximum
- C++ program to find out the maximum possible tally from given integers
- C++ Program to find out the maximum amount of score that can be decreased from a graph

Advertisements