Created
April 23, 2012 18:24
-
-
Save kdmkdmkdm/2472886 to your computer and use it in GitHub Desktop.
cout3rdValue?C++
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> | |
| #include <string> | |
| using namespace std; | |
| int main() | |
| { | |
| int x[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | |
| for(int i = 0; i <= (8 - 1); ++i) | |
| { | |
| // if the value we are searching for = 3... | |
| if(x[i] = 3) | |
| { | |
| int position = i; | |
| break; | |
| } | |
| else | |
| { | |
| continue; | |
| } | |
| } | |
| } |
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] == 3) | |
| { | |
| 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