Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created July 2, 2014 07:08
Show Gist options
  • Select an option

  • Save cocodrips/a4838f6121d6b1648f12 to your computer and use it in GitHub Desktop.

Select an option

Save cocodrips/a4838f6121d6b1648f12 to your computer and use it in GitHub Desktop.
pairの配列を作りたい
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 5;
int main(int argc, char const *argv[])
{
pair<int, int> areas[N*N];
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < N; ++j)
{
pair<int, int> p;
p.first = i * i + j * j;
p.second = i;
areas[i * N + j] = p;
}
}
for (int i = 0; i < N * N; ++i)
{
cout << areas[i].first << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment