Add build scripts for C# and

unify the coding style.
This commit is contained in:
krahets
2023-02-08 22:18:02 +08:00
parent 38751cc5f5
commit 6dc21691ed
63 changed files with 2703 additions and 3911 deletions
@@ -435,24 +435,9 @@ comments: true
=== "C#"
```csharp title="linked_list.cs"
// 在链表的结点 n0 之后插入结点 P
void Insert(ListNode n0, ListNode P)
{
ListNode n1 = n0.next;
n0.next = P;
P.next = n1;
}
[class]{linked_list}-[func]{insert}
// 删除链表的结点 n0 之后的首个结点
void Remove(ListNode n0)
{
if (n0.next == null)
return;
// n0 -> P -> n1
ListNode P = n0.next;
ListNode n1 = P.next;
n0.next = n1;
}
[class]{linked_list}-[func]{remove}
```
=== "Swift"
@@ -556,17 +541,7 @@ comments: true
=== "C#"
```csharp title="linked_list.cs"
// 访问链表中索引为 index 的结点
ListNode Access(ListNode head, int index)
{
for (int i = 0; i < index; i++)
{
if (head == null)
return null;
head = head.next;
}
return head;
}
[class]{linked_list}-[func]{access}
```
=== "Swift"
@@ -652,19 +627,7 @@ comments: true
=== "C#"
```csharp title="linked_list.cs"
// 在链表中查找值为 target 的首个结点
int Find(ListNode head, int target)
{
int index = 0;
while (head != null)
{
if (head.val == target)
return index;
head = head.next;
index++;
}
return -1;
}
[class]{linked_list}-[func]{find}
```
=== "Swift"