Created
April 23, 2012 21:28
-
-
Save kdmkdmkdm/2473979 to your computer and use it in GitHub Desktop.
lineSearchNewC++
This file contains hidden or 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
| #include "stdafx.h" | |
| #include <iostream> | |
| using namespace std; | |
| int main() | |
| { | |
| int x[8] = {78, 48, 23, 94, 12, 60, 84, 55}; | |
| int position = -1; | |
| for(int i = 0; i <= (8 - 1); ++i) | |
| { | |
| // if the value we are searching for = 3... | |
| if(x[i] == 94) | |
| { | |
| // assign i to position. | |
| position = i; | |
| break; | |
| } | |
| else | |
| { | |
| continue; | |
| } | |
| } | |
| cout << position << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment