fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Edge{
  5. int vert1;
  6. int vert2;
  7. int weight;
  8. Edge* next;
  9. };
  10.  
  11. Edge* append(Edge *head, int origin, int destination, int weight) {
  12. Edge *temp = new Edge;
  13. temp = head;
  14. Edge *node = new Edge;
  15. while (temp->next != NULL){
  16. temp = temp->next;
  17. }
  18. node->vert1 = origin;
  19. node->vert2 = destination;
  20. node->weight = weight;
  21. node->next = NULL;
  22. if (head == 0) {
  23. head = node;
  24. }
  25. else if (head != 0){
  26. node = temp;
  27. }
  28. return head;
  29. }
  30.  
  31. int main() {
  32. // your code goes here
  33. Edge* list = new Edge;
  34. list = append(list,1,1,2);
  35. return 0;
  36. }
Success #stdin #stdout 0s 2812KB
stdin
Standard input is empty
stdout
Standard output is empty