Home > database >  Practice 3
Practice 3

Time:10-04




7 # include & lt; stdio.h>

Int main ()

{

Double k, sum, s1=0, s2=0, s3=0;

For (k=1; K & lt;=100; K++)

{

S1 +=k;

}

For (k=1; K & lt;=50; K++)

{

S2 +=k * k;

}

For (k=1; K & lt;=10; K++)

{

S3 +=1/k;

}

Sum=s1 + s2 + s3;

Printf (" sum=% 10.4 f \ n ", sum);

return 0;

}

8.
# include "stdio.h"
Void main ()
{
Int a, b, c;
For (a=1; A<=9; +)
{
For (b=0; b<=9; B++)
{
For (c=0; C<=9; C + +)
{
If (a * 100 * 10 + b + c==a * a * b + a + b * b * c * c * c)
{
Printf (" % d % d % d \ n ", a, b, c);
}
}
}
}
}



9.
#include

Int main ()
{
Int I, j, sum;/* I said to gauge number, j said factor, the factor is the sum of the sum said */

For (I=2; I & lt;=1000; I++)
{
Sum=1;
For (j=2; J & lt;=I/2; J++)
If (I % j==0)/* judgment can be divided exactly by j, I can j factor is the factor does not include their own */
The sum +=j;

If (sum==I)/* determine whether the number is equal to the factor is the sum of */
{
Printf (" % d its factors are 1, ", I); Output the number/* */

For (j=2; J & lt;=I/2; J++)
If (I % j==0) printf (" % d ", j);/* */output factor

printf("\n");
}
}

return 0;
}
10.
#include

Int main ()
{
Int I, j, sum;/* I said to gauge number, j said factor, the factor is the sum of the sum said */

For (I=2; I & lt;=1000; I++)
{
Sum=1;
For (j=2; J & lt;=I/2; J++)
If (I % j==0)/* judgment can be divided exactly by j, I can j factor is the factor does not include their own */
The sum +=j;

If (sum==I)/* determine whether the number is equal to the factor is the sum of */
{
Printf (" % d its factors are 1, ", I); Output the number/* */

For (j=2; J & lt;=I/2; J++)
If (I % j==0) printf (" % d ", j);/* */output factor

printf("\n");
}
}

return 0;
}
11.
# include & lt; stdio.h>
Int main ()
{
Double I, s=0, x=100, y;
for(i=1; i<=10; I++)
{
Y=x/2;
S=s + x + y;
X=y;
}
S=s - y;
Printf (" altogether after: % lf m \ n ", s);
The tenth rebound: printf (" % lf m \ n ", y);
return 0;
}
12.
#include
Int main ()
{
int i;
Int sum;
For (I=0; i<9. I++)
{
Sum=sum (+ 1) * 2;
}
Printf (" % d ", sum);
return 0;
}

13.
#include
#include
Int main () {
Double x1, x2,
Float a;
The scanf (" % f ", & amp; a);
X2=1.0;
For (;; ) {
The x1 x2=;
(x1 + x2=a/x1)/2.0;
If (fabs (x1, x2) & lt; 0.00001) {
Printf (" % f ", x2);
break;
}
}
Return 0;
}

14.

  • Related