-
1. Because sum is additive, it should be 0 at the beginning. In this way, sum+= can be used later. If you don't start with sum=0, sum may be a random number, and it doesn't make sense to add it later.
2. Because if you only write 1, it is an int number by default, and i is also an int number, then 1 i is the 1 of the int type divided by 3, or divided by 5, 7....Wait, it's all 0. Because integer division ignores the decimal part.
If double is preceded, the whole division is considered to be a double divided by a double,。。 Wait, it's the correct decimal result.
-
sum=0 is initialization, sum += (double)1 i; That is, sum = sum + (double)1 i, each time the sum of the previous one plus the value after the denominator is incremented, the sum obtained is the sum.
-
Programmable and calculates and outputs 1+5+9+13+17
Hello, dear, program calculation and output 1+5+9+13+17, output integer between 1--10 2, output .1003, output .994, output the number between 100 and 200 that can be divisible by 7, and calculate the number between 100 and 200 that can be divided by 7 5, calculate 1 + 2 + 3 + 4 + 5 + ...
100=?6. Calculate 1[2]+2[2]+3[2]+4[2]+5[2]+100[2]=?
Note: The parentheses represent the square) 7, calculate 1x2x3x4x5x6x....10=?
8. Calculate 1x2+2x3+3x4+4x5+5x6+6x7+7x8+...99x100=?9. Calculate 1+3+5+7+9+...
99=?10. Calculate 2+4+6+8+10+...100=?
3. Use the for loop to achieve 1, and output the number between 1-10 in reverse order12. Reverse output23. Reverse order output .
14. Calculate the -.. 1-2-3-4-5100=?5. Count Zen land calculation 1 + 5 + 9 + 13 + 17 + 21 + 25 + 29 + 33 + 37 + 41 + 45 = ?
6. Output the number that can be divisible by 6 between 100--200, and calculate how many numbers can be divisible by 6 between 100--200 7. 8. Randomly generate a 1--10 number, require the design of the boundary and enter a 1--10 number, if you guess correctly, then output "you are so smart", otherwise the output "and then pick up the attack and then work hard" 9, develop a function, print 101 999 all the number of daffodils Remarks:
A daffodil number refers to an n-digit number (n3) whose sum of the n-power of the numbers on each bit is equal to itself, (e.g., 1 3 + 5 3 + 3 3 = 153).
-
Summary. Hello, the basic idea of this program is to combine each addition first, and then sum it.
I'll write one for you in python first, and other language ideas are figured out, if you have other language needs, you can tell me.
First, programmatically construct all the data into a list
1) Put the first of nine numbers in the list.
2) Get the last number in the list.
3) Multiply the last number of the list by 10 + the last digit of the last number by 1 to get a new number.
3) The new number is saved to the last one in the list.
Write a program that calculates 1+12+123+...Hello 123456789, the basic idea of this program is to combine each addition first, and then sum it. I'll write one for you in python first, and other language ideas are figured out, if you have other language needs, you can tell me.
First of all, program and construct all the data into the list: (1) put the first of the nine numbers in the list (2) get the last number of the list (3) multiply the last number of the list by 10 + the last digit of the last number by 1 to get the new number (3) save the new number to the last ...... of the list
Now it's a simple list summation:
Gives you a pasteable **:l=[1]n=len(l)while n<9: last=l[n-1] new=last*10+(last%10+1) n=len(l)sum=0for i in l:
sum=sum+i print(sum)
-
Summary. Hello, dear! We're happy to answer for you! Write a program, enter a positive integer n, and calculate 1-1 3 +1 5 ......The first n items and: As shown in the picture, I hope my answer can help the kiss, and I wish the kiss a happy life.
Write a program, enter a positive integer n, and calculate 1-1 3 +1 5 ......The first n terms and.
Hello, dear! We're happy to answer for you! Write a program, enter a positive integer n, and calculate 1-1 3 +1 5 ......The first n items and: As shown in the picture, I hope my answer can help the kiss, and I wish the kiss a happy life.
Can it be a little clearer.
This one comes out like this, kissing.
-
Solution: Algorithm 1: Periodic cycle: the first step, let s=0, i=1;
The second step, if i 999 is true, then the third step is executed; Otherwise, output s, end algorithm;
Step 3, s = s+i;
Step 4, i=i+2, go back to step 2.
Algorithm 2: Until the type loop: the first step, let s=0, i=1;
The second step, s=s +i;
The third step, i=i+2;
The fourth step, if i is not greater than 999, turn to the second step; Otherwise, output s, end algorithm;
VB design.
Introduction. What is required. >>>More
--- programmer (one of the following).
1) Reach the required standard number of hours of formal training for professional programmers, and obtain a certificate of completion (completion). >>>More
Add 2 buttons, 2 textboxes, 1 listbox, and you can't go wrong. >>>More
The last sentence is wrong, you have already swapped the values of the original b and c in the second if sentence, which means that the value of a must be greater than the value of c, and at this time, the value of a is not necessarily greater than the value of b, so this is not good.
First of all, let's introduce the method of deleting the stubborn update folder in the win2000 system (the method is similar to the winxp win2k3 system). >>>More