https://www.acmicpc.net/problem/10818 : μ΅μ, μ΅λ
c++
λ«κΈ°#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
ββββint n = 0;
ββββcin >> n;
ββββint *num = new int[n];
ββββfor (int i = 0; i < n; i++){
ββββββββint a;
ββββββββcin >> a;
ββββββββnum[i] = a;
ββββ}
ββββsort(num, num + n);
ββββcout << num[0] << " " << num[n-1] << endl;
ββββdelete[] num;
}
-> algorithm ν€λνμΌμ sort ν¨μ μ¬μ©
https://www.acmicpc.net/problem/2562 : μ΅λκ°
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint max = -1, num = 0;
ββββfor(int i=0; i<9; i++){
ββββββββint a;
ββββββββcin >> a;
ββββββββif(max < a){
ββββββββββββmax = a;
ββββββββββββnum = i+1;
ββββββββ}
ββββ}
ββββcout << max << endl;
ββββcout << num << endl;
}
리μ€νΈ μμ°κ³ .. κ·Έλ₯.....
https://www.acmicpc.net/problem/2577 : μ«μμ κ°μ
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint a, b, c;
ββββint arr[10] = {0};
ββββcin >> a >> b >> c;
ββββint num = a * b * c;
ββββwhile(num != 0){
ββββββββarr[num%10]++;
ββββββββnum /= 10;
ββββ}
ββββfor(int i=0; i<10; i++){
ββββββββcout << arr[i] << endl;
ββββ}
}
https://www.acmicpc.net/problem/3052 : λλ¨Έμ§
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint arr[42] = {0};
ββββfor(int i=0; i<10; i++){
ββββββββint num;
ββββββββcin >> num;
ββββββββarr[num%42]++;
ββββ}
ββββint count = 0;
ββββfor(int i=0; i<42; i++){
ββββββββif(arr[i]!=0) count++;
ββββ}
ββββcout << count;
}
https://www.acmicpc.net/problem/1546 : νκ·
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint n, max = 0;
ββββdouble total = 0;
ββββcin >> n;
ββββdouble *score = new double[n];
ββββdouble *n_score = new double[n];
ββββfor(int i = 0; i < n; i++){
ββββββββdouble s;
ββββββββcin >> s;
ββββββββscore[i] = s;
ββββββββmax = (s > max) ? s : max;
ββββ}
ββββfor(int i = 0; i < n; i++){
ββββββββn_score[i] = score[i] * 100 / max ;
ββββββββtotal += n_score[i];
ββββ}
ββββcout << total/n << endl;
}
https://www.acmicpc.net/problem/8958 : OX ν΄μ¦
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint n;
ββββcin >> n;
ββββfor(int i=0; i<n; i++){
ββββββββint total = 0, score = 0;
ββββββββstring test;
ββββββββcin >> test;
ββββββββfor (int i = 0; i < test.length(); i++){
ββββββββββββif(test[i] == 'O'){
ββββββββββββββββscore += 1;
ββββββββββββββββtotal += score;
ββββββββββββ}else{
ββββββββββββββββscore = 0;
ββββββββββββ}
ββββββββ}
ββββββββcout << total << endl;
ββββββββtotal = 0, score = 0;
ββββ}
}
https://www.acmicpc.net/problem/4344 : νκ· μ λκ² μ§
c++
λ«κΈ°#include <iostream>
using namespace std;
int main(void){
ββββint c;
ββββcin >> c;
ββββfor(int i = 0; i < c; i++){
ββββββββint n;
ββββββββdouble total = 0;
ββββββββcin >> n;
ββββββββint *score = new int[n];
ββββββββfor(int j=0; j<n; j++){
ββββββββββββcin >> score[j];
ββββββββββββtotal += score[j];
ββββββββ}
ββββββββdouble avg = total / n;
ββββββββdouble m = 0;
ββββββββfor(int j=0; j<n; j++){
ββββββββββββif(score[j] > avg)
ββββββββββββββββm += 1;
ββββββββ}
ββββββββdouble per = m * 100 / n;
ββββββββprintf("%.3f%%\n", per);
ββββ}
}
νλ©΄ ν μλ‘ νμ΄μ¬μ΄ μ΅κ³ λΌλ μκ°λ§ λλκ±Έ.....?...... νμ΄μ¬ μ΅κ³ λ€...