π•ƒπ•¦π•„π•šπ•£

728x90
λ°˜μ‘ν˜•

Min 2

[C++][header][algorithm] min maxγ€Žλͺ©μ°¨γ€ 0. μ„€λͺ…에 μ•žμ„œ 1. Default Constructor 2. Custom Constructor 3. Initializer List Constructor 0. std::min & std::max γ€Žμ„€λͺ…에 μ•žμ„œγ€ μ°Έκ³  1. ①비ꡐ할 값듀이 λ§Žκ±°λ‚˜, β‘‘ArrayㆍVector와 같은 일련의 μ»¨ν…Œμ΄λ„ˆμ— μ €μž₯λ˜μ–΄ μžˆλ‹€λ©΄, μ΅œμ†Œκ°’γ†μ΅œλŒ€κ°’μ„ κ΅¬ν•˜κΈ° μœ„ν•΄ min_element λ˜λŠ” max_element ν•¨μˆ˜λ₯Ό μ‚¬μš©ν•  수 μžˆλ‹€. (ν•΄λ‹Ή ν•¨μˆ˜μ— λŒ€ν•΄μ„œλŠ” λ‚˜μ€‘μ— ν¬μŠ€νŒ… ν•˜κ² λ‹€.) 2. std::min와 std::maxλŠ” algorithm λΌμ΄λΈŒλŸ¬λ¦¬μ— 3가지 ν˜•νƒœλ‘œ μ‘΄μž¬ν•œλ‹€. γ€Žβ‘  Default Constructor 』 γ€Žβ‘‘ Custom Constructor 』 γ€Žβ‘’ Initializer List Construct..2023. 2. 22.
[C][Macro] min maxγ€Žλͺ©μ°¨γ€ 1. The old C macro way 2. The new improved gccㆍclang "statement expression" way 3. [C++] std::min() & std::max() 4. 좜처 1. The old C macro way 맀크둜 μ›ν˜• /* min */ #define min(a, b) (((a) (b)) ? (a) : (b)) 단점 : double-evaluation side effect λ°œμƒ /* Input */ #include #define min(a, b) (((a) (b)) ? ..2023. 2. 21.
728x90
λ°˜μ‘ν˜•