因此,考虑到以下条件,这是正确的:
条件:
curr为null
public HttpResponseMessage Get(Guid id)
{
var path = HttpContext.Current.Server.MapPath(string.Format("/OriginalImages/{0}.jpg", id));
byte[] fileData = File.Exists(path) ? File.ReadAllBytes(path) : new byte[0];
MemoryStream ms = new MemoryStream(fileData);
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(ms.ToArray());
result.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
return result;
}
前面的语句是否正确地将节点Q插入到链表中?
答案 0 :(得分:0)
我无法理解将节点添加到单链表末尾的逻辑。您的行if (prev.next.next == curr)
未定义为prev.next本身为null
。我添加了一个片段,用于在链接列表的末尾添加节点。
void append(int data){
Node node = new Node(data);
if(head==null){
head = new Node(int data);
return;
}
new_node.next = null;
Node last = head;
while (last.next != null)
last = last.next;
last.next = new_node;
return;
}