Skip to content

Instantly share code, notes, and snippets.

@kdmkdmkdm
Created April 23, 2012 18:24
Show Gist options
  • Select an option

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

Select an option

Save kdmkdmkdm/2472886 to your computer and use it in GitHub Desktop.
cout3rdValue?C++
#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;
}
}
}
#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