π¦ Changgo/π BaaaaaarkingDog
[BOJ][C++] λ°±μ€ 2587λ²: λνκ°2 (μμ½λ)
μ λ¬
2023. 5. 12. 23:35
λ°μν
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];}
λ°μν