[ create a new paste ] login | about

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

C++, pasted on May 21:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

#define N 10

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

	for (int t = 0; t < N; t++)
	{
		A[t] = rand() % (N-1) + 1;
		printf("%d ",A[t]);
	}

	printf("\n\n");

	for (int i = 0; i < N; i++)
	{
		int mul = 1;
		for (int j = 0; j <= i; j++)
			mul*=A[j];

		printf("mul = %d\n", mul);
	}

	printf("\n");

	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
2 8 1 8 6 8 2 4 7 2 

mul = 2
mul = 16
mul = 16
mul = 128
mul = 768
mul = 6144
mul = 12288
mul = 49152
mul = 344064
mul = 688128



Create a new paste based on this one


Comments: