我的错误是什么意思?我该如何解决?
当我尝试运行程序时,请参阅此处以获取错误照片...
http://postimg.org/image/horh6d26j/
我的程序正在尝试删除双链表的最后一个元素并将其插入到前面
我只是想执行 backToFront 函数。该活动是我大学 2011 年过去的实践考试(?)我正在努力完成它以准备我的实践考试 - 这是在两天内(aaahhhhhhh !!!!!!)
/*
* backToFront.c
* comp1917 pracExam #2 2011s1 UNSW
*
* Author: WRITE YOUR NAME HERE
* Date: 21 June 2011
* License: Public Domain
*/
// Implement the backToFront function below
// so that it moves the last node in a non-empty linked list
// of nodes to be the first node in the list, leaving the
// relative position of all the other nodes unchanged.
// You may assume the input list contains at least one node.
//
// Your function should do the moving by changing pointers
// in the nodes and list structs, (don't use malloc or make
// any new nodes)
//
// Your function should return the new list.
//
// You need to pass the tests in testBackToFront.c
//
// Compile and run the tests using
// gcc -Wall -Werror -O -o tester backtToFront.c testBackToFront.c
// ./tester
//
// When a test fails look in the testBackToFront.c file to see
// what the test was testing. There are 3 tests in that file.
//
// Once you have passed all the tests you have finished.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "backToFront.h"
list backToFront (list items) {
assert (items.first != NULL);
nodePtr current = items.first;
nodePtr previous = NULL;
while (current != NULL){
previous = current;
current = current->rest;
}
current->rest = items.first;
items.first = current;
previous->rest = NULL;
return items;
}
/*
* backToFront.h
* pracExam 2011
*
* Created by Richard Buckland on 26/07/09.
* Modified by David Collien on 20/06/11.
* Copyright 2011. All rights reserved.
*
*/
// DO NOT ALTER OR SUBMIT THIS FILE
// we will use our own copy when marking
typedef struct _node *nodePtr;
typedef struct _list {
nodePtr first;
} list;
// For le sorution, add /samplesolutions at the end of your url
typedef struct _node {
int value;
nodePtr rest;
} node;
// given a node (*item) and a list of nodes (items)
// this function takes the last node of the list
// and moves it to be the first node in the list.
//
// the function returns the altered list.
//
// (note that the function does not create new nodes
// or change the value field of existing nodes.)
list backToFront (list items);