User
Pass
2FA
 
 

Problema Recursivitate

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Homework zone
Author Message1041
coldice

[Creep]



Status: Offline
(since 02-02-2016 12:42)
Joined: 06 Dec 2010
Posts: 610, Topics: 66
Location: Romania

Reputation: 29.7
Votes: 16

 
Post Posted: 16-03-2011, 13:30:52 | Translate post to: ... (Click for more languages)

Trebuie sa fac un program in c++ care sa utilizeze o subrutina recursiva....

Programul trebuie sa caute o valoare , in cadrul unui sir citit de la tastatura.




0 0
  
Back to top
View user's profile Send private message
Radytz

[Mentally Stable]



Status: Offline
(since 12-09-2011 16:30)
Joined: 20 Feb 2011
Posts: 38, Topics: 2
Location: Pitesti

Reputation: 87.3
Votes: 2

Post Posted: 06-04-2011, 13:20:38 | Translate post to: ... (Click for more languages)

Tocmai ce am avut-o de facut ca tema -

#include<iostream.h>


CautareBinara(int A[], int valoarea,int stanga,int dreapta) {
if (dreapta < stanga)
return -1 // s-a terminat cautarea si nu s-a gasit
mid = (stanga+dreapta)/2
if (A[mid] > valoarea)
return CautareBinara(A, value, low, mid-1)
else if (A[mid] < valoarea)
return CautareBinara(A, value, mid+1, high)
else
return mid // gasit
}

void main()
{
int x;
int n;int a[30];
cout<<"nr de elemente ale vectorului:";cin>>n;
int i;
for(i=0;i<n;i++)
{
cout<<"a["<<i<<"]=";cin>>a[i];
}
cout<<"elementul cautat este:";cin>>x;
int aux=CautareBinara(a[],x,0,n);
if(aux==-1)
cout<<"elementul nu s-a gasit";
else
cout<<"elementul este la pozitia:"<<aux;
}

0 0
  
Back to top
View user's profile Send private message
coldice

[Creep]



Status: Offline
(since 02-02-2016 12:42)
Joined: 06 Dec 2010
Posts: 610, Topics: 66
Location: Romania

Reputation: 29.7
Votes: 16

 
Post Posted: 01-05-2011, 19:21:41 | Translate post to: ... (Click for more languages)

Radytz wrote:
Tocmai ce am avut-o de facut ca tema -
[...]
}



cam tarziu bre, deja am luat nota 2-




0 0
  
Back to top
View user's profile Send private message

  Topic locked


Topic is closed, you cannot post any messages in it anymore




 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Homework zone  


The time now is 21-02-2025, 18:51:04
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password