백준 1330, 9498, 2753, 14681, 10950(C++, python)

이푸름·2021년 10월 7일
0
post-custom-banner

1330 두 수 비교하기

C++

#include <iostream>
using namespace std;

int main(void)
{
	int a, b;

	cin >> a >> b;

	if (a > b)
		cout << ">" << endl;
	else if (a < b)
		cout << "<" << endl;
	else
		cout << "==" << endl;
	return (0);
}

python

a, b = map(int, input().split())

if a > b :
	print ('>')
if a < b :
	print ('<')
if a == b :
	print ('==')

9498 시험 성적

C++

#include <iostream>
using namespace std;

int main(void)
{
	int score;

	cin >> score;
	if (90 <= score && score <= 100)
		cout << 'A' << endl;
	else if (80 <= score && score <= 89)
		cout << 'B' << endl;
	else if (70 <= score && score <= 79)
		cout << 'C' << endl;
	else if (60 <= score && score <= 69)
		cout << 'D' << endl;
	else
		cout << 'F' << endl;
	return (0);
}

python

score = int(input())

if 90 <= score and score <= 100:
	print('A')
elif 80 <= score and score <= 89:
	print('B')
elif 70 <= score and score <= 79:
	print('C')
elif 60 <= score and score <= 69:
	print('D')
else:
	print('F')

2753 윤년

C++

#include <iostream>
using namespace std;

int main(void)
{
	int year;

	cin >> year;
	if ((year % 4 == 0) && (year % 100 != 0 || year % 400 == 0))
		cout << 1 << endl;
	else
		cout << 0 << endl;
	return (0);
}

python

year = int(input())

if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
	print(1)
else:
	print(0)

14681 사분면 고르기

C++

#include <iostream>
using namespace std;

int main(void)
{
	int x, y;

	cin >> x >> y;
	if (x < 0 && y > 0)
		cout << 2 << endl;
	else if (x > 0 && y > 0)
		cout << 1 << endl;
	else if (x < 0 && y < 0)
		cout << 3 << endl;
	else
		cout << 4 << endl;
	return (0);

}

python

x = int(input())
y = int(input())

if x > 0 and y > 0:
	print(1)
elif x < 0 and y > 0:
	print(2)
elif x < 0 and y < 0:
	print(3)
else:
	print(4)

10950 A+B - 3

C++

#include <iostream>
using namespace std;

int main(void)
{
	int n, a, b;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a >> b;
		cout << a + b << endl;
	}
	return(0);
}

python

n = int(input())
for i in range(n):
	a, b = map(int, input().split())
	print(a+b)
          
post-custom-banner

0개의 댓글