Skip to content

Commit 6b22bb9

Browse files
authored
Update README_EN.md
1 parent 4e9aab5 commit 6b22bb9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

solution/0000-0099/0002.Add Two Numbers/README_EN.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ proc addTwoNumbers(l1: var SinglyLinkedList, l2: var SinglyLinkedList): SinglyLi
493493
#### C
494494
495495
```c
496+
496497
/**
497498
* Definition for singly-linked list.
498499
* struct ListNode {
@@ -501,39 +502,35 @@ proc addTwoNumbers(l1: var SinglyLinkedList, l2: var SinglyLinkedList): SinglyLi
501502
* };
502503
*/
503504

504-
struct ListNode *addTwoNumbers(struct ListNode *l1, struct ListNode *l2)
505-
{
506-
struct ListNode *dummy = (struct ListNode *)malloc(sizeof(struct ListNode));
505+
struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
506+
struct ListNode* dummy = (struct ListNode*) malloc(sizeof(struct ListNode));
507507
dummy->val = 0;
508508
dummy->next = NULL;
509-
struct ListNode *curr = dummy;
509+
struct ListNode* curr = dummy;
510510
int carry = 0;
511511

512-
while (l1 != NULL || l2 != NULL || carry != 0)
513-
{
512+
while (l1 != NULL || l2 != NULL || carry != 0) {
514513
int sum = carry;
515-
if (l1 != NULL)
516-
{
514+
if (l1 != NULL) {
517515
sum += l1->val;
518516
l1 = l1->next;
519517
}
520-
if (l2 != NULL)
521-
{
518+
if (l2 != NULL) {
522519
sum += l2->val;
523520
l2 = l2->next;
524521
}
525522

526523
carry = sum / 10;
527524
int val = sum % 10;
528525

529-
struct ListNode *newNode = (struct ListNode *)malloc(sizeof(struct ListNode));
526+
struct ListNode* newNode = (struct ListNode*) malloc(sizeof(struct ListNode));
530527
newNode->val = val;
531528
newNode->next = NULL;
532529
curr->next = newNode;
533530
curr = curr->next;
534531
}
535532

536-
struct ListNode *result = dummy->next;
533+
struct ListNode* result = dummy->next;
537534
free(dummy);
538535
return result;
539536
}

0 commit comments

Comments
 (0)