λ°μν
https://www.acmicpc.net/problem/2587
2587λ²: λνκ°2
μ΄λ€ μλ€μ΄ μμ λ, κ·Έ μλ€μ λννλ κ°μΌλ‘ κ°μ₯ ννκ² μ°μ΄λ κ²μ νκ· μ΄λ€. νκ· μ μ£Όμ΄μ§ λͺ¨λ μμ ν©μ μμ κ°μλ‘ λλ κ²μ΄λ€. μλ₯Ό λ€μ΄ 10, 40, 30, 60, 30μ νκ· μ (10 + 40 + 30 + 60 +
www.acmicpc.net
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int sum=0;
vector<int>input (5);
for(int i=0; i<5; i++) {
cin >> input[i];
sum += input[i];
}
sort(input.begin(), input.end());
cout << sum/5 << "\n" << input[2];
return 0;
}
μμ½λ©
#include <bits/stdc++.h>
using namespace std;int main(){int s=0;int n[5];for(int i=0;i<5;i++){cin>>n[i];s+=n[i];}sort(n,n+5);cout<<s/5<<"\n"<<n[2];}
λ°μν
'π Baaaaaarking > 0x02κ° - κΈ°μ΄ μ½λ μμ± μλ Ή II' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[BOJ][C++] λ°±μ€ 2440λ²: λ³ μ°κΈ° - 3 (0) | 2023.05.18 |
---|---|
[BOJ][C++] λ°±μ€ 1267λ²: νΈλν° μκΈ (0) | 2023.05.17 |
[BOJ][C++] λ°±μ€ 2576λ²: νμ (0) | 2023.05.11 |
[BOJ][C++] λ°±μ€ 2490λ²: μ·λμ΄ (0) | 2023.05.10 |
[λ°±μ€/BOJ][CμΈμ΄] 2480λ²: μ£Όμ¬μ μΈκ° (0) | 2021.05.20 |