發表文章

目前顯示的是 11月, 2016的文章

JAVA 7.12

圖片
import   java.util.Scanner ; public   class  ReverseArray  {      public   static   void  main ( String [ ]  args )   {          int  i ;          int   [ ] iList  =   new   int   [ 10 ] ;          int   [ ] iList2  =   new   int   [ 10 ] ;         Scanner input  =    new  Scanner ( System . in ) ;          // input array          for   (  i = 0   ;  i < 10   ;  i ++   )             iList [ i ]   =  input. nextInt ( ) ;         iList2  =  Reverse ( iList,iList. length ) ;          for   (  i = 0   ;  i < 10   ;  i ++   )              System . out . print ( iList2 [ i ] + " " ) ;                                          }      public   static   int [ ]  Reverse ( int   [ ]  array, int  L )      {      int  i,j ;      int   [ ] iCopy  =   new   int   [ 10 ] ;      for   (  i = 0  ,j = L - 1   ;  j >= 0   ;  j -- ,i ++   )         iCopy [ i ]   =  array [ j ] ;      return  iCopy ;         }

JAVA 7.10

圖片
import   java.util.Scanner ; public   class  Findlargest  {      public   static   void  main ( String [ ]  args )   {          int  i ;          int   [ ] iBucket  =   new   int   [ 10 ] ;         Scanner input  =    new  Scanner ( System . in ) ;          for   (  i = 0   ;  i < 10   ;  i ++   )             iBucket [ i ]   =  input. nextInt ( ) ;          System . out . println ( FindL ( iBucket ) ) ;      } // method find largest      public   static   int  FindL  ( int [ ]  array  )      {      int  Temp ;     // find largest      int  j ;     Temp  =   - 1 ;      for   (  j = 0   ;  j < 10   ;  j ++   )          {          if   ( array [ j ]   >  Temp  )             Temp  =  array [ j ] ;          }      return  Temp ;      } } Find the largest element in the array

JAVA 7.8

圖片
import   java.util.Scanner ; public   class  Sumarray  {      public   static   void  main ( String [ ]  args )   {      int [ ]  iBucket  =   new   int [ 10 ] ;      double   [ ]  dBucket  =   new   double [ 10 ] ;     Scanner input  =    new  Scanner ( System . in ) ;      int  i ;      for   (  i = 0   ;  i < 10   ;  i ++   )          {         iBucket [ i ]   =  input. nextInt ( ) ;         dBucket [ i ]   =  input. nextDouble ( ) ;          }      System . out . println ( sum  ( iBucket ) ) ;      System . out . println ( sum  ( dBucket ) ) ;      }      public   static   int  sum  ( int [ ]  array  )      {      int  j,iSum ;     iSum  =   0 ;      for   (  j = 0   ;  j < 10   ;  j ++   )         iSum  +=  array [ j ] ;      return  iSum ;      }      public   static   double  sum  ( double [ ]  array  )      {      int  j ;      double  dSum  =   0.0 ;      for   (  j = 0   ;  j < 10  

JAVA---chapter 7.5

圖片
import   java.util.Scanner ; public   class  Counteven  {      public   static   void  main ( String [ ]  args )   {          int  iCountEven ;                   // count even number;          int  i  =   - 1 ;         Scanner input  =   new  Scanner ( System . in ) ;          int   [ ] iBucket  =   new   int   [ 20 ] ;          do              {             i ++;             iBucket [ i ]   =  input. nextInt ( ) ;              System . out . print ( iBucket [ i ] ) ;              } while   ( iBucket [ i ] != 0 ) ;          int  j ;         iCountEven  =   0 ;          for   (  j = 0   ;  j < i  ;  j ++   )             {              if   (  iBucket [ j ]   %   2   ==   0   )                 iCountEven ++;             }          System . out . println ( " Even number have : "   +  iCountEven  ) ;          System . out . println ( "Odd number have : "   +   ( i - iCountEven ) ) ;      } }

MASM --- chapter7 binary multiplication

Include Irvine32 . inc .data . code main proc mov   eax ,   123 mov   ebx ,   eax shl   eax ,   5                ;  multiply by 2^5 shl   ebx ,   2                ;  multiply by 2^2 add   eax ,   ebx call  writedec call  crlf exit main endp end main eax * 36 = eax * ( 32 + 4 )