sh_04_ cumulative sum

 

sh_04_ cumulative sum

1  # calculation result of the cumulative sum of all the numbers between 0 and 100 
2  # variable 0. define the final result 
. 3 Result = 0
 . 4  
. 5  # number 1. Define an integer variable cycle record 
. 6 I = 0
 . 7  
. 8  # 2 start cycle 
. 9  the while i <= 100 :
 10      Print (i)
 . 11  
12 is      # each cycle, let the result of this counter variable i and the sum 
13 is      result + = i
 14  
15      # processing counter 
16      i + =. 1
 . 17  
18 is  Print ( " digital summation result between% D = 100 ~ 0 " % result)

 

Guess you like

Origin www.cnblogs.com/shaohan/p/11496459.html