operators/motivation/a.cs - Comparison of operator notation and function notation. | Lecture 6 - slide 2 : 20 Program 1 |
using System; public class OperatorsOrNot { public static int With (int a, int b, int c, int m){ return (a % m + b % m + c % m) / 3; } public static int Without (int a, int b, int c, int m){ return MyInt.Quotient( MyInt.Plus( MyInt.Plus( MyInt.Remainder(a,m), MyInt.Remainder(b,m)), MyInt.Remainder(c,m)), 3); } // In some languages, such as Lisp, // with more liberal identifiers rules: // (/ (+ (% a m) (% b m) (% c m)) 3) public static void Main(){ Console.WriteLine(With(18,19,25, 7)); // 4 Console.WriteLine(Without(18,19,25, 7)); // 4 } }