アルゴリズムに問題があります。必要なのは、再帰を介して配列の要素を乗算することです。これが私がこれまでに得たものです:
#include <stdio.h>
void vector(int vec[],int tam) {
// gets a simple array
int i;
for (i=0; i<tam; i++) {
printf("Ingrese un numero: ");
scanf("%d",&vec[i]);
}
}
int mv(int vec[], int tam, int pos) {
// need help with the base and general case!
if (tam==0) {
return 1;
} else {
return vec[pos]*mv(vec,tam,pos+1);
}
}
int main() {
int vec[3];
vector(vec,3);
printf("%d",mv(vec,3,0));
}