forked from rakeshcusat/Code4Reference
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dd82a3
commit 8422b9a
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <iostream> | ||
#include <stack> | ||
|
||
using namespace std; | ||
|
||
void find_number(int array[],int size,int num){ | ||
|
||
for(int index=0;index<size;) | ||
{ | ||
if(array[index] == num){ | ||
cout<<"Found the number at index = "<<index<<endl; | ||
return; | ||
} | ||
index += num-array[index]; | ||
} | ||
cout<<"Couldn't find the number "<<endl; | ||
} | ||
int main(int argc, char **argv){ | ||
|
||
int myarray[]={3,4,5,4,3,2,3,4,5,6,7,8,9,10,9}; | ||
find_number(myarray, sizeof(myarray)/sizeof(int),7); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters