Poor Lifting Method!
/*
==================================================================
Title: All the numbers within 10000 are counted and output in the following format, for example:
28=1+2+4+7+14.
Note: The finish count is in addition to itself. The value equals the sum of all the factors including 1!
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 include 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 in this problem lies in the format of the output, the inference of the completion number is a simple problem, even can use for loop to
Realize!
However, you want to export the format required by the topic. You must first find all of its factors and save it 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 inferred + output + is initialized again after the next n is counted. Until the N>n follow
Loop ends (Note that you cannot use a for loop.) Otherwise it will output n times repeatedly).
========================================================================
*/
The basic algorithm of C language 38-all finished in formatted output 10000