A C language problem, I don t know how to start

Updated on technology 2024-04-10
5 answers
  1. Anonymous users2024-02-07

    The above method needs to calculate the factor twice, the complexity increases, you can use the array to store the factor, the complete program is as follows.

    #include

    int main()

    int i,j,sum=0;

    int a[1000]=;The array holds the factor for(i=1; i<1000;i++)

    sum=0;k=0;

    for(j=1;j<=i/2;j++)

    if (i%j==0) judgment factor.

    a[k++]=j;Factors are stored in an array.

    sum+=j;Find the sum of factors.

    if(sum==i) if the sum of the factors is equal to itself printf("%5d",i);Output line breaks and the number itself printf(" its factors are :");

    for(j=0;jreturn 0;

  2. Anonymous users2024-02-06

    int i,j,k,sum=0;

    int a[50];

    k=0;for(i=1;i<1000;i++)sum=0;

    for(j=1;j<=i/2;j++)

    if (i%j==0)

    sum=sum+j;

    if(sum==i)

    a[k++]=i;

    Then you can re-output the value of array a, and then make a loop output when you take its factor.

  3. Anonymous users2024-02-05

    Accumulate from 1 and validate with each additional value:

    If the product is more than 1000, exit the loop, otherwise verify:

    Whether the product is equal to the sum is the output.

  4. Anonymous users2024-02-04

    #include

    #include

    using namespace std;

    int main()

    int n;

    int sum;

    int i,j,k;

    for(i = 1;i<=1000;i++)sum = 0;

    n = i;

    for(k = 2;kif(n%k == 0)

    sum += k;

    if(i == sum+1)

    Cout: This method is a bit high, I don't know if this has a requirement, you try it.

  5. Anonymous users2024-02-03

    No, because there is not enough work.

Related questions
12 answers2024-04-10

while(j<=i) is an endless loop.

int j=0 should be j=1 >>>More

8 answers2024-04-10

It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a); >>>More

20 answers2024-04-10

To be precise, it's not superpowers or magic.,The water behind the right seat of the god mentioned the clues of the fantasy killer in the fourteen volumes.,From his words, it can be inferred that the right hand of the upper strip is related to the ultimate purpose of the right seat of the god.,And the fourteenth volume also mentions the concept of the god.,The pronunciation of the god is the same as that of the upper one.,And then when he fought against the alchemist before,The right hand of the upper strip was broken.,Out of it is the head of the dragon king.,And the last party of the fifteen volumes passed the note they got with the English word "dragon", And the ability of the right side of the fire (note the right side of the name) that has the same power as the previous one in the 20 volumes, and the explosion of hemp at the end. From all of the above, it can be inferred that the power of the right hand may be the original sin, and that if the power is perfect, it can become God. Of course, this is still just speculation, let's see how the hippo is going to write.

35 answers2024-04-10

Is this love fraternity, or love? I didn't get it. What about my advice, live up to the people who love you, pay attention to details, and give love. >>>More

15 answers2024-04-10

You don't take the initiative too much, if you are too active, he will not know how to cherish you with his heart, men are like this, but you can start with the person next to him, don't say it first, let them help you, you will have more opportunities, even if you can't get it, you can be a good friend.