Lets say I enter 27 (the result of LowestOne's post) and I want to check if thats a cube..
Do cbrt(27) which will give you the result of 3, then use that return value to perform your n x n x n, and if the result of that calculation matches what the user entered then we have ourself a cube.
You need to split the 3-digit number into it's component digits. To do that notice that number % 10 give you the least significant digit of an integer and number / 10 drops the least significant digit. Figure out how to combine these to extract the 3 digits into 3 separate variables. I'll call them a, b, and c.
Once you have a b and c, you can check if the sum of their cubes equals the original number.
#include <iostream>
usingnamespace std;
int main()
{
int firstnumber,secondnumber,thirdnumber;
cout<<"Put first number"<<endl;
cin>>firstnumber;
cout<<"Put second number"<<endl;
cin>>secondnumber;
cout<<"Put third number"<<endl;
cin>>thirdnumber;
cout<<"Three digits number is:"<<firstnumber<<secondnumber<<thirdnumber<<endl;
}
Hi all.
I want to help you, so JUST(its really bad algorithm! it cant work for big numbers and really its terrible! don't use it!) for tomorrow lets make a code that have and for and it have and int like i and it will +1 each cycle and check if i^3 is equals to the given number or no.
But as the others said, the better way to solve this problem, is make the given number to the prime numbers(3 prime number) and see if the ^3 of them is equal to the given number or not, i think you can use goldenbakh idea too, search it on a search engine and see the result.
If my idea is not true please someone tell it, now i cant make focus on the program because ... . :D
Have Nice Life.
EDIT: I think i didn't get your question, so :D i'm sorry about it if i cant help you
Well now you can easily get the entire number by multiplying firstnumber by 100, secondnumber by 10, and then adding those to thirdnumber. Then it's just a matter of comparing the cubes to that.