Poor Lifting Method!
/*
==================================================================
Title: For all the completed numbers within 10000, the statistic quantity and output in the following format:
28=1+2+4+7+14.
Note: The end count is the sum of all the factors that contain 1, except for itself!
such as: 28 of all factors are: 1,2,4,7,28, in addition to 28 other factors and = 28, so 28 is the end of the number!
==================================================================
*/
#include <stdio.h>
#define N 10000
int ws (int a)
{
int i=1;
int sum=0;
while (I<A)//does not contain a, because the factor of the completion number must be less than it itself!
{
if (a%i==0)
Sum+=i;
i++;
}
if (sum==a)
return 1;
else return 0;
}
void Main ()
{
int n=2,i,j,k=0,a[100],shu=0;
printf ("The end of%d is:", N);
while (n<=n)
{
if (WS (n))
{
for (i=1;i<n;i++)
if (n%i==0)
A[k++]=i;
printf ("\n%d:%-4d=%d", shu+1,n,a[0]);
for (j=1;j<k;j++)
printf ("+%d", A[j]);
printf (". \ n");
shu++;
k=0;
}
n++;
}
printf ("\ n altogether%d", Shu);
printf ("\ n");
}
/*
======================================================================
Evaluation:
The difficulty lies in the format of the output, the judgment is a simple problem, and can even be used for a loop to
Realize! However, in order to output the required format, all of its factors must be obtained before being saved in a pre-defined
Array, first output N=A[0], followed by a for loop to output the remaining + factors, in the output ".".
It is important to note that an output is determined by the + output + reinitialization after the next n is counted. Until the N>n follow
Loop ends (Note that you cannot use a for loop, otherwise the output is repeated n times).
========================================================================
*/
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The basic algorithm of C language 38-all the finished numbers in the formatted output 10000