Home > Back-end >  Is there a big help me to mark off the meaning of each step! I don't understand the program
Is there a big help me to mark off the meaning of each step! I don't understand the program

Time:06-05

#include

Int main ()
{
Int a, b, c, d=0, e=0;
The scanf (" % d ", & amp; A);//input a number
For (b=0; B<=a; B++)//
{
D=0;
For (c=1; C<=a; C + +)
{
If (b % c==0)
{
D++;

}
}
If (d==2)
{
If (a % b==0)//judge b is a business
{
If (e{
E=a/b;
}
}

}
}
Printf (" % d ", e);//output is one of the biggest business
return 0;
}

CodePudding user response:

Read hundreds of times, its righteousness see, read write more debugging

CodePudding user response:

reference 1st floor SuperDay response:
read hundreds of times, its righteousness see, read write more debugging

Frontal  , well said, can only rely on myself

CodePudding user response:

Initial guess,
A is a given number of
B cycle
Do factorization with the cycle of c to b
Said d==2 b is a prime number, because the only prime number can only a factor of 2
E saved is the biggest factor
aFeel this program is not perfect, the purpose is to find a biggest factor

If for this purpose, this algorithm can optimize the part is large, find out the smallest prime factor, a biggest factor directly came out, why the back of the loop

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related