Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ammmma
Hi there! Hi! struct node { int data; node* next; }; node* reverse(node* head) { node* cur = head; node* prev = NULL; node* next; while (curr != NULL) { next = cur->next; cur->next = prev; prev = cur; cur = next; } return prev; } // e.g. "1 2 3" -> 1->2->3->NULL node* generateList(string foo); bool checkListEqual(node* h1, node* h2) { while (h1) { if (h1->data != h2->data) return false; h1 = h1->next; if (h2) h2 = h2->next; else return false; } if (h2) return false; return true; } int main() { node* l1 = generateList(""); node* l2 = generateList("1"); node* l3 = generateList("1 2 3"); if (reverse(l1) == NULL) cout << "ok"; if (checkListEqual(reverse(reverse(l1)), l1) ) cout << "ok"; if (checkListEqual(reverse(reverse(l2)), l2) ) cout << "ok"; if (checkListEqual(reverse(reverse(l3)), l3) ) cout << "ok"; } // hello bool match(string& str1, string& str2, int) { }
run
|
edit
|
history
|
help
0
float precision test
Click 5
IAR compiler bug test code
Prosta implementacja algorytmu Euklidesa (NWD)
TemplateRemove
CPP - Arrays - Ex.2
不带头结点的单链表
HashRK
kickstartd
Minimum Vertices to Traverse Directed Graph