Skip to content

Instantly share code, notes, and snippets.

@MasazI
Created May 29, 2015 06:21
Show Gist options
  • Save MasazI/b2a5c3a7e617cbb9a3d9 to your computer and use it in GitHub Desktop.
Save MasazI/b2a5c3a7e617cbb9a3d9 to your computer and use it in GitHub Desktop.
minmax.cpp(C++11)
//
// minmax.cpp
// CplusplusPractice
//
// Created by masai on 2015/05/29.
// Copyright (c) 2015年 masai. All rights reserved.
//
#include <iostream>
#include <vector>
int main(int argc, char* argv[]){
double x = 10.34, y = 3.5, z = 4.3;
// コンテナ
std::vector<double> v = {x, y, z};
auto minmax = std::minmax_element(v.begin(), v.end());
std::cout << "min: " << *minmax.first << std::endl;
std::cout << "max: " << *minmax.second << std::endl;
// 初期化子
auto t1 = std::minmax(1,999);
std::cout << "min: " << t1.first << std::endl;
std::cout << "max: " << t1.second << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment