Click here to Skip to main content
15,907,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:02
professionalChris Losinger18-Apr-11 10:02 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:13
sadas232341s18-Apr-11 10:13 
GeneralRe: Duplicates in list Pin
David Crow18-Apr-11 18:02
David Crow18-Apr-11 18:02 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:54
sadas232341s18-Apr-11 9:54 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:14
professionalChris Losinger18-Apr-11 10:14 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:16
sadas232341s18-Apr-11 10:16 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:19
professionalChris Losinger18-Apr-11 10:19 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:25
sadas232341s18-Apr-11 10:25 
OK, here is the full code that I' m working on. Can you tell me my mistakes exactly because I can' t understand where to put what. The UniqueList function is important, which now only shows the list and nothing more. The sort does not work...

#include "iostream"

using namespace std;

void Add(int n);
void UniqueList(int N);

struct Elem
{
	int key;
	Elem *prev;
	Elem *next;
} *start;

int main()
{
	int num;
	int N = 0;

	start = NULL;

	while(cin >> num)
	{
		Add(num);

		N++;
	}
	
	cout << endl;

	UniqueList(N);

	return 0;
}

void Add(int n)
{
	Elem *p = start;
	start = new Elem;

	start->key = n;
	start->next = p;
	start->prev = NULL;
	
	if(NULL != p) p->prev = start;
}

void UniqueList(int N)
{
	Elem *p = start;
	int t;

	if(NULL != start) cout << "List:" << endl;
	else cout << "Empty list!";

	for(int i = 1; i < N; i++)
		for(int j = N - 1; j >= i; j--)
		{
			if(p->key > p->next->key)
			{
				t = p->key;
				p->key = p->next->key;
				p->next->key = t;
			}
		}

	while(NULL != p)
	{
		cout << p->key << endl;

		p = p->next;
	}
}

GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:32
sadas232341s18-Apr-11 10:32 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:50
professionalChris Losinger18-Apr-11 10:50 
GeneralRe: Duplicates in list [modified] Pin
sadas232341s18-Apr-11 10:51
sadas232341s18-Apr-11 10:51 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 11:03
professionalChris Losinger18-Apr-11 11:03 
QuestionCritique is Need Pin
Ikeman from Moses Lake18-Apr-11 7:09
Ikeman from Moses Lake18-Apr-11 7:09 
Question[SOLVED] I need to copy (CTRL+C) a web page... C++ [modified] Pin
Ram Shmider18-Apr-11 1:43
Ram Shmider18-Apr-11 1:43 
AnswerRe: I need to copy (CTRL+C) a web page... C++ Pin
_AnsHUMAN_ 18-Apr-11 2:20
_AnsHUMAN_ 18-Apr-11 2:20 
GeneralRe: I need to copy (CTRL+C) a web page... C++ Pin
Ram Shmider19-Apr-11 20:20
Ram Shmider19-Apr-11 20:20 
AnswerRe: I need to copy (CTRL+C) a web page... C++ Pin
Nitheesh George18-Apr-11 18:27
Nitheesh George18-Apr-11 18:27 
GeneralRe: I need to copy (CTRL+C) a web page... C++ Pin
Ram Shmider19-Apr-11 20:18
Ram Shmider19-Apr-11 20:18 
QuestionHow can I solve those errors? Pin
Abder_Rahman18-Apr-11 0:26
Abder_Rahman18-Apr-11 0:26 
AnswerRe: How can I solve those errors? Pin
Richard MacCutchan18-Apr-11 0:52
mveRichard MacCutchan18-Apr-11 0:52 
GeneralRe: How can I solve those errors? Pin
Abder_Rahman18-Apr-11 23:52
Abder_Rahman18-Apr-11 23:52 
QuestionApplication crashing while using cablib.dll Pin
tomydevasia18-Apr-11 0:05
tomydevasia18-Apr-11 0:05 
AnswerRe: Application crashing while using cablib.dll Pin
Richard MacCutchan18-Apr-11 0:48
mveRichard MacCutchan18-Apr-11 0:48 
Questionhow to drag and drop image in listview control using mfc Pin
rajniyadav1a17-Apr-11 21:29
rajniyadav1a17-Apr-11 21:29 
AnswerRe: how to drag and drop image in listview control using mfc Pin
Niklas L18-Apr-11 5:51
Niklas L18-Apr-11 5:51 

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.