Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C language exercise - beginner Pin
CPallini6-Oct-21 22:46
mveCPallini6-Oct-21 22:46 
GeneralRe: C language exercise - beginner Pin
David Crow7-Oct-21 2:08
David Crow7-Oct-21 2:08 
AnswerRe: C language exercise - beginner Pin
jsc427-Oct-21 5:18
professionaljsc427-Oct-21 5:18 
GeneralRe: C language exercise - beginner Pin
Graham Breach7-Oct-21 11:30
Graham Breach7-Oct-21 11:30 
GeneralRe: C language exercise - beginner Pin
Bram van Kampen15-Oct-21 13:35
Bram van Kampen15-Oct-21 13:35 
GeneralRe: C language exercise - beginner Pin
Richard MacCutchan15-Oct-21 22:04
mveRichard MacCutchan15-Oct-21 22:04 
AnswerRe: C language exercise - beginner Pin
Bram van Kampen15-Oct-21 13:29
Bram van Kampen15-Oct-21 13:29 
Questiondata structure Pin
User 153459235-Oct-21 15:05
User 153459235-Oct-21 15:05 
Given following definition for singly linked list node and a pointer type:

 

struct Node {

     int num;

     Node* next;

     Node() = delete;

     Node(int num) : num{ num }, next{ nullptr } {}

};

 

typedef Node* NodePtr;

 

 

Use following prototype:

 

void quiz2(NodePtr& head1, NodePtr& target, NodePtr& head2)

 

to design a function that:

Takes in two linked lists, indicated by head1 and head2, and a NodePtr target
Searches target Node in linked list 1 (by comparing address, not by value):
If found, then connect the whole linked list 2 to the target node. In other words, use list 2 to replace nodes after target. Also update head2 to nullptr as the merged linked list should have only one entry point at head1.
If not found, then connect list 2 to the end of list 1, and set head2 to nullptr for the same above reason.
 

For example,

list 1: 10->20->30->40, target is the address of node 20, list 2: 11->12->13, then after calling the function, list 1 should be 10->20->11->12->13.
list 1: 10->20->30->40, target is an address that cannot be found in list 1, list 2: 11->12->13, then after calling the function, list 1 should be 10->20->30->40->11->12->13.
 

When merging, please take care of memory and do not let leak happen. You will be deducted by 10 points if memory leak happens. (Hint: in the first example, what should happen to nodes 30 and 40?)

 

Submit one .cpp file as your answer to Quiz 2.

 

Develop your own work and DO NOT CHEAT. Violator will be found, reported, and penalized with F grade for this course. 

 

Attach FileNo file chosen 


modified 3-Nov-21 21:01pm.

AnswerRe: data structure PinPopular
Dave Kreskowiak5-Oct-21 17:11
mveDave Kreskowiak5-Oct-21 17:11 
AnswerRe: data structure Pin
Maximilien6-Oct-21 12:44
Maximilien6-Oct-21 12:44 
AnswerRe: data structure Pin
Bram van Kampen15-Oct-21 12:50
Bram van Kampen15-Oct-21 12:50 
QuestionRun powershell in C# Pin
jwradhe23-Sep-21 0:43
jwradhe23-Sep-21 0:43 
AnswerRe: Run powershell in C# Pin
Richard MacCutchan23-Sep-21 0:49
mveRichard MacCutchan23-Sep-21 0:49 
AnswerRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 1:14
mveRichard Deeming23-Sep-21 1:14 
GeneralRe: Run powershell in C# Pin
jwradhe23-Sep-21 1:48
jwradhe23-Sep-21 1:48 
GeneralRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 2:43
mveRichard Deeming23-Sep-21 2:43 
GeneralRe: Run powershell in C# Pin
jwradhe23-Sep-21 2:49
jwradhe23-Sep-21 2:49 
GeneralRe: Run powershell in C# Pin
Richard Deeming23-Sep-21 3:21
mveRichard Deeming23-Sep-21 3:21 
GeneralRe: Run powershell in C# Pin
Dave Kreskowiak23-Sep-21 3:29
mveDave Kreskowiak23-Sep-21 3:29 
QuestionExample C code to use API "GetProcessIoCounters" Pin
Narasimha Moorthy20-Sep-21 1:01
Narasimha Moorthy20-Sep-21 1:01 
AnswerRe: Example C code to use API "GetProcessIoCounters" Pin
Richard MacCutchan20-Sep-21 1:11
mveRichard MacCutchan20-Sep-21 1:11 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Narasimha Moorthy20-Sep-21 19:14
Narasimha Moorthy20-Sep-21 19:14 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Richard MacCutchan20-Sep-21 21:19
mveRichard MacCutchan20-Sep-21 21:19 
GeneralRe: Example C code to use API "GetProcessIoCounters" Pin
Victor Nijegorodov20-Sep-21 21:21
Victor Nijegorodov20-Sep-21 21:21 
QuestionConnect to bluetooth service watch and read HR data Pin
Wim Van den Borre19-Sep-21 23:18
Wim Van den Borre19-Sep-21 23:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.