All pastes #1422508 Raw Edit

Robert

public cpp v1 · immutable
#1422508 ·published 2009-05-14 09:57 UTC
rendered paste body
// DuplicateChecker.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>#include <sstream>using namespace std;int digitsCheck(int input){	char text[50];	sprintf_s(text, "%i", input);	return (int) strlen(text);}int _tmain(int argc, _TCHAR* argv[]){	int values[500];	int limit = 0;	while (true)	{		cout << "Please enter how many nodes you wish to have in your array: ";		cin >> limit;		if (limit <= 0 || limit > 500)			cout << "Invalid amount, please enter a value from 1 to 500." << endl;		else			break;	}	int digits = digitsCheck(limit);	for (int i=0; i<limit; i  )	{		ostringstream oss;		oss << i 1;				string node = oss.str();		for (int d=node.length(); d<digits; d  )			node = "0"   node;		cout << "[" << node << "]=";		cin >> values[i];	}	bool firstWritten = true;	for (int i=0; i<limit; i  )	{		if (values[i] != NULL)		{			bool dupStatus = false;			for (int j=i 1; j<limit; j  )			{				if (values[i] == values[j])				{					dupStatus = true;					values[j] = NULL;				}			}			if (!dupStatus)			{				if (!firstWritten)					cout << ", ";				else					firstWritten = false;				cout << values[i];			}		}	}	cout << endl;	return 0;}