Skip to content

Instantly share code, notes, and snippets.

@kdmkdmkdm
Created April 23, 2012 21:28
Show Gist options
  • Select an option

  • Save kdmkdmkdm/2473979 to your computer and use it in GitHub Desktop.

Select an option

Save kdmkdmkdm/2473979 to your computer and use it in GitHub Desktop.
lineSearchNewC++
#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