[백준 24736] Football Scoring (C#, C++) - soo:bak
작성일 :
문제 링크
설명
두 팀의 미식축구 득점 항목이 주어질 때, 각 팀의 총점을 계산하는 문제입니다.
접근법
터치다운은 6점, 필드골은 3점, 세이프티와 2점 전환은 각각 2점, PAT은 1점입니다.
각 항목의 개수에 점수를 곱해서 더하면 총점이 됩니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
class Program {
static int Score(int t, int f, int s, int p, int c) => 6 * t + 3 * f + 2 * s + p + 2 * c;
static void Main() {
for (var i = 0; i < 2; i++) {
var line = Console.ReadLine()!.Split();
var t = int.Parse(line[0]);
var f = int.Parse(line[1]);
var s = int.Parse(line[2]);
var p = int.Parse(line[3]);
var c = int.Parse(line[4]);
Console.Write(Score(t, f, s, p, c));
Console.Write(i == 0 ? " " : "\n");
}
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto score = [](int t, int f, int s, int p, int c) {
return 6 * t + 3 * f + 2 * s + p + 2 * c;
};
for (int i = 0; i < 2; i++) {
int t, f, s, p, c; cin >> t >> f >> s >> p >> c;
cout << score(t, f, s, p, c);
cout << (i == 0 ? ' ' : '\n');
}
return 0;
}