Reformat the C# codes.

Disable creating new line before open brace.
This commit is contained in:
krahets
2023-04-23 03:03:12 +08:00
parent ac6eece4f3
commit 73dcb4cea9
49 changed files with 561 additions and 1135 deletions

View File

@ -4,61 +4,38 @@
namespace hello_algo.include;
/// <summary>
/// Definition for a singly-linked list node
/// </summary>
public class ListNode
{
/* Definition for a singly-linked list node */
public class ListNode {
public int val;
public ListNode? next;
/// <summary>
/// Generate a linked list with an array
/// </summary>
/// <param name="x"></param>
public ListNode(int x)
{
public ListNode(int x) {
val = x;
}
/// <summary>
/// Generate a linked list with an array
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
public static ListNode? ArrToLinkedList(int[] arr)
{
/* Generate a linked list with an array */
public static ListNode? ArrToLinkedList(int[] arr) {
ListNode dum = new ListNode(0);
ListNode head = dum;
foreach (int val in arr)
{
foreach (int val in arr) {
head.next = new ListNode(val);
head = head.next;
}
return dum.next;
}
/// <summary>
/// Get a list node with specific value from a linked list
/// </summary>
/// <param name="head"></param>
/// <param name="val"></param>
/// <returns></returns>
public static ListNode? GetListNode(ListNode? head, int val)
{
while (head != null && head.val != val)
{
/* Get a list node with specific value from a linked list */
public static ListNode? GetListNode(ListNode? head, int val) {
while (head != null && head.val != val) {
head = head.next;
}
return head;
}
public override string? ToString()
{
public override string? ToString() {
List<string> list = new();
var head = this;
while (head != null)
{
while (head != null) {
list.Add(head.val.ToString());
head = head.next;
}