📄 test.cs
字号:
namespace Utils
{
using System;
/// <summary>
/// This the test harness
/// </summary>
public class Test
{
public static void Main()
{
int x; // input value 1
int y; // input value 2
int greater; // result from Greater()
int f; // factorial result
bool ok; // factorial success/failure
// Get input numbers
Console.WriteLine("Enter first number:");
x = int.Parse(Console.ReadLine());
Console.WriteLine("Enter second number:");
y = int.Parse(Console.ReadLine());
// Test the Greater() method
greater = Utils.Greater(x,y);
Console.WriteLine("The greater value is ", greater);
// Test the Swap() method
Console.WriteLine("Before swap: " + x + "," + y);
Utils.Swap(ref x,ref y);
Console.WriteLine("After swap: " + x + "," + y);
// Get input for factorial
Console.WriteLine("Number for factorial:");
x = int.Parse(Console.ReadLine());
// Test the factorial function
ok = Utils.Factorial(x, out f);
// Output factorial results
if (ok)
Console.WriteLine("Factorial(" + x + ") = " + f);
else
Console.WriteLine("Cannot compute this factorial");
// Test the factorial function (recursive version)
ok = Utils.RecursiveFactorial(x, out f);
if (ok)
Console.WriteLine("Factorial(" + x + ") = " + f + " (recursive)");
else
Console.WriteLine("Cannot compute this factorial (recursive)");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -