[ create a new paste ] login | about

Link: http://codepad.org/txFiMJ8k    [ raw code | output | fork ]

C++, pasted on Dec 25:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

const int m = 20;

int main(int argc, char* argv[])
{
	int* A = new int[m];
	memset((void*)A, 0x00, sizeof(int) * m);

	for (int z = 0; z < m; z++)
	{
		A[z] = rand() % 9 + 1;
		printf("%d ",A[z]);
	}

	printf("\n");

	int cnt = 0;
	for (int i = 0; i < m; i++)
	{
		int count = 0;
		for (int r = 0; r < m; r++)
			if (A[r] == A[i]) count++;

		if (count <= 1) 
		{
			printf("%d ",A[i]);
			cnt++;
		}
	}

	printf("\ncount = %d\n",cnt);

	return 0;
}


Output:
1
2
3
2 8 1 8 6 8 2 4 7 2 6 5 6 8 6 5 7 1 8 2 
4 
count = 1


Create a new paste based on this one


Comments: