i need your help.please

For all 6-digit numbers from 100000 to 999999, find the numbers that, if you add the top three digits to the bottom three digits, and square the result, it will equal the original number.
i have being able to generate six digit numbers but can't add first three to the second three.any help for me please.do u think arrays can work out here.
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iostream>

using namespace std;
int main()
{
for ( int x = 100000; x < 999999; x++ )
{
cout<< x <<endl;
int first3;
int second3 ;
}
system("PAUSE");
return 0;

}
You can get the top 3 digits by dividing each number by 1000
And you get the bottom 3 by doing number % 1000

E: you can make your search easier by starting at the first 3 digit number that when squared will equal a 6 digit number (317) and end at 999. Then for each number, you square it and add the first 3 digits to the bottom 3. If you don't get the number you squared, this is not one of them
Last edited on
can u kindly help me with the code structure.please. i need to capture first 3 and add the last 3.what code format am to use
1
2
3
4
5
6
7
8
9
10
11
int main()
{	
	for ( int r = 317; r < 1000; ++r )
	{
		int sq = r*r;
		if ( sq divided by 1000 plus sq mod 1000 == r )
			//...
	}
  	
	return 0;
}
i have an issue sir,am not able to capture the first 3 digits to add to the last 3 digits.please can u assist me.this my line of code so far.
{
for ( int x =100000; x < 999999; x++ )
{
//cout<< x <<endl;
int sum,result;
int firstpart= x/1000;
int secondpart =x/1000;
sum = firstpart + secondpart;
result=sum*sum;

cout<<firstpart<< "and" <<secondpart<<"="<<sum<<" " "the square is"<<result<<endl;

}
//system("PAUSE");
return 0;

}
Topic archived. No new replies allowed.