プログラミング道場 ACM/ICPC

ソートする

最終更新:

kit

- view
メンバー限定 登録/ログイン

簡単にソートする


ベクターや配列の要素を並び替えます.

#include <iostream>
#include <algorithm>
#define N 5

int a[N] = {3, 2, 5, 4, 1};

using namespace std;

void print()
{
  for (int i = 0; i < N; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}

int main()
{
  print();
  sort(a, a+N);
  print();
  return 0;
}
人気記事ランキング
ウィキ募集バナー