class1.cs
来自「C#开发教程 由浅入深 配有实例 是初学者的好帮手」· CS 代码 · 共 42 行
CS
42 行
using System;
namespace MathOps
{
class MathOpsApp
{
[STAThread]
static void Main(string[] args)
{
// The System.Random class is part of the .NET
// Framework class library. Its default constructor
// seeds the Next method using the current date/time.
Random rand = new Random();
int a, b, c;
a = rand.Next() % 100; // Limit max to 99.
b = rand.Next() % 100; // Limit max to 99.
Console.WriteLine("a={0} b={1}", a, b);
c = a * b;
Console.WriteLine("a * b = {0}", c);
// Note the following code uses integers. Therefore,
// if a is less than b, the result will always
// be 0. To get a more accurate result, you would
// need to use variables of type double or float.
c = a / b;
Console.WriteLine("a / b = {0}", c);
c = a + b;
Console.WriteLine("a + b = {0}", c);
c = a - b;
Console.WriteLine("a - b = {0}", c);
c = a % b;
Console.WriteLine("a % b = {0}", c);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?