Problem with an recursion

Hi! My task is to find n-numbers which sum of pow(of it numbers) For example I must input N=3 ,and program must show me 100 .
Where is my mistake ??
Last edited on
1
2
3
4
5
6
7
8
9
10
11
void suma(int chislo, int i) {
	if(i > n)
		return;
	//supposse i == n here
	int buf;
	int buf2 = pow(10, n - 1 - i); //n - 1 - n = -1, 10^-1 = 0.1 -> int(0.1) = 0

	buf = chislo % buf2; //division by 0
	a[i] = chislo / buf2; //division by 0
	suma(buf, i + 1);
}


Also
1
2
int n;	
int *a=new int[n];	//¿what's the value of `n' right at this point? 
Yes! Thank you, I must create my dynamic array after inputting n from keyboard...
Topic archived. No new replies allowed.