[ create a new paste ] login | about

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

C++, pasted on Dec 9:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 20

const int n = 25;

int convert(int n)
{
	int val = 0;
	for (int i = 0; n >= 1; i++)
	{
		val+=((int)((n % 7) * pow((double)10,i)));
		n/=7;
	}

	return val >= 0 ? val : -1;
}

int main(int argc, char* argv[])
{
	int A[N] = { 0 };
	for (int i = 0; i < N; i++)
	{
		int val = rand() % 100 + n;
		A[i] = convert(val);
		printf("%d ",A[i]);
	}

	return 0;
}


Output:
1
213 216 204 55 226 114 216 225 134 64 153 103 223 150 154 102 122 102 166 115 


Create a new paste based on this one


Comments: