Probleme Recursivitate incepatori vectori

download Probleme Recursivitate incepatori vectori

of 1

Transcript of Probleme Recursivitate incepatori vectori

  • 7/21/2019 Probleme Recursivitate incepatori vectori

    1/1

    1.Suma valorilor impare dintr-un vector#includeint n,i,v[100];int suma(int i,int n) {

    if(i>n) return 0; else if(v[i]%2!=0) return v[i]+suma(i+1,n);

    else return suma(i+1,n);}int main(){

    cin>>n;for(i=1;i>v[i];coutn;cout>n;for(i=1;i>v[i];coutn) return 0; else if(v[i]>0) return 1+ suma(i+1,n);

    else return suma(i+1,n);}int main(){

    cin>>n;for(i=1;i>v[i];cout