Advertisement
kk258966

3/18 物件導向程式設計 練習三

Mar 18th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.23 KB | None | 0 0
  1. public class B10207081_4{
  2.     public static void main(String args[]){
  3.    
  4.    
  5.     int i,sum=0;
  6.                    
  7.         for(i=1;i<=30;i++)
  8.         {
  9.             if(i%2==1)
  10.             sum=sum+i;
  11.            
  12.            
  13.         }
  14.        
  15.         System.out.println("1-30 奇數總和"+sum);
  16.          
  17.    
  18.     }
  19.    
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement