[ create a new paste ] login | about

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

C, pasted on Sep 15:
#include <stdio.h>
int f(int (*d)[2], int n)
{
	int p = 0, cnt;
	for (int i = 2; i*i <= n; ++i)
	{
		for (cnt = 0; n % i == 0; cnt++, n /= i) {}
		if (cnt == 0)
			continue;
		d[p][0] = i;
		d[p++][1] = cnt;
	}
	if (n > 1)
	{
		d[p][0] = n;
		d[p++][1] = 1;
	}
	return p;
}
int main(void)
{
	int n;
	scanf("%d", &n);
	int d[100][2];
	int p = f(d, n);
	return 0;
}


Output:
1
2
In function 'f':
Line 5: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: