It was written in c++ specifically for my problem.
I did not steal it.
I have built some thing close.
But it gives me the right a right pair numbers many times .
for input 54 it gives me 12 42 12 42 12 42 (it should give me only one pair) 12 42
and it doesnt give me the result for 53 52 .. 1
(whether they are a sum of two abounded numbers)
i tried to trace with a debugger but i cant see the problem
??
Code:
#include <stdio.h>
//////////////////////////////////////////////////////////////00000000
int main(){
int num;
int index,tndex,kndex,jndex;
int flag_1,flag_2,same_num;
int sum;
int smallest,smallest_ever,smallest_ever_2;
sum=0;
same_num=-1;
smallest=-1;
printf("enter number\n");
scanf("%d",&num);
for(index=1;index<num;index++){ //start for main number
flag_1=0;
sum=0;
flag_2=0;
tndex=index;
kndex=num-tndex;
sum=0;
for(jndex=1;jndex<tndex;jndex++){//start abbondence check for first num (tndex)
if (tndex%jndex==0){
sum=sum+jndex;
}
if (tndex<sum){
flag_1=1;
}
}//end abbondence check for first num
sum=0;
for(jndex=1;jndex<kndex;jndex++){//start abbondence check for second num (kndex)
if (kndex%jndex==0){
sum=sum+jndex;
}
if (kndex<sum){
flag_2=1;
}
}//end abbondence check for first num
if ((flag_2==1)&&(flag_1==1)){ //start flag check
if (kndex>=tndex){
smallest=tndex;
if ((smallest<smallest_ever)&&(smallest>1)){
smallest_ever=smallest;
smallest_ever_2=kndex;
}
}
else
{
smallest=kndex;
if ((smallest<smallest_ever)&&(smallest>1)){
smallest_ever=smallest;
smallest_ever_2=tndex;
}
}
printf("%d %d\n",smallest_ever,smallest_ever_2);
}
}//end flag check
return 0;
}//end main