Skip to content

Instantly share code, notes, and snippets.

@KentaYamada
Created April 21, 2016 14:52
Show Gist options
  • Select an option

  • Save KentaYamada/53418e25f0d1f81e48920eb02f513a9f to your computer and use it in GitHub Desktop.

Select an option

Save KentaYamada/53418e25f0d1f81e48920eb02f513a9f to your computer and use it in GitHub Desktop.
Vectorを参照渡しして使う
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<unsigned int> runs;
static void InitRuns()
{
runs.push_back(0x20);
runs.push_back(0x40);
}
static unsigned int Check(const vector<unsigned int> &condition, unsigned int value)
{
for(size_t i = 0; i < condition.size(); ++i)
{
if(condition[i] == value)
{
return 1;
}
}
return 0;
}
int main(int argc, char *argv[])
{
unsigned int a = 0x20;
unsigned int b;
InitRuns();
b = Check(runs, a);
cout << "Value: " << b << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment