CSharp Algorithm - Replace multiplication operator with a method
/*
Author: Jiangong SUN
*/
 
How to replace multiplication operation with a method? For example, you have two integers as method entries, and you will get a result of their multiplication.
You need just another point of view as to this problem. You can have a for loop for iterating one parameter, and add another parameter to variable result in this loop.
Here is the implementation.
        private static int Multiplication(int x, int y)
        {
            int result = 0;
            for (int i = 0; i < x; i++)
            {
                result += y;
            }
            return result;
        }
 I hope this article can do help to you! Enjoy coding!
 
                    
                 
                
            
         
         
 浙公网安备 33010602011771号
浙公网安备 33010602011771号