@stefannibrasil/

ShimmeringGlumAcouchi

C

No description

fork
loading
Files
  • main.c

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6003685665552367","path":"main.c","file":{"path":"main.c","content":{"asEncoding":{"base64":"I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgcHJvZHV0byhpbnQgdltdLCBpbnQgbik7CgppbnQgbWFpbih2b2lkKSB7CiAgICAvLyBEaXNhYmxlIHN0ZG91dCBidWZmZXJpbmcKICAgIGludCB2WzRdID0gezIsIC0xLCAzLCA0fTsKICAgIGludCBuID0gNDsKICAgIGludCByZXN1bHRhZG8gPSBwcm9kdXRvKHYsIG4pOwogICAgcHJpbnRmKCJyZXN1bHQ6ICVkIFxuIiwgcmVzdWx0YWRvKTsKICAgIHJldHVybiAwOwp9CgppbnQgcHJvZHV0byAoaW50IHZbXSwgaW50IG4pIHsKICAgaWYobiA9PSAxKXsKICAgCSByZXR1cm4gdlswXTsKICAgfQogICBpZih2W24tMV0gPiAwKXsKICAgCSByZXR1cm4gdltuLTFdICogcHJvZHV0byh2LCBuLTEpOwogIH0KCXJldHVybiBwcm9kdXRvKHYsbi0xKTsKfQo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

int produto(int v[], int n);

int main(void) {
    // Disable stdout buffering
    int v[4] = {2, -1, 3, 4};
    int n = 4;
    int resultado = produto(v, n);
    printf("result: %d \n", resultado);
    return 0;
}

int produto (int v[], int n) {
   if(n == 1){
   	 return v[0];
   }
   if(v[n-1] > 0){
   	 return v[n-1] * produto(v, n-1);
  }
	return produto(v,n-1);
}