-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLibrary.cs
58 lines (54 loc) · 1.29 KB
/
Library.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Linq;
namespace OurCompany;
public class Library
{
public static int ReadInteger(string prompt = "Number", string signal = ":")
{
Console.Write($"{prompt}{signal} ");
return Convert.ToInt32(Console.ReadLine());
}
public static void RepeatChar(char content, int times)
{
for (int i = 1; i <= times; i++)
{
Console.Write(content);
}
}
public static void IntDivision(int dividend, int divisor,
out int quocient, out int remainder)
{
quocient = dividend / divisor;
remainder = dividend % divisor;
}
public static void PrintIntArray(int[] array, string label = null, bool inline = true)
{
if (inline)
{
if (label != null)
{
Console.Write($"{label}: ");
}
// Open Bracket
Console.Write("[");
// All elements but the last one
for (int i = 0; i < array.Length - 1; i++)
{
Console.Write($"{array[i]}, ");
}
// Last element and the close bracket
Console.WriteLine($"{array[array.Length - 1]}]");
}
else
{
if (label != null)
{
Console.WriteLine($"{label}:");
}
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine($"[{i}]: {array[i]}");
}
}
}
}