2557๋ฒ โ Hello world
#include <iostream>
using namespace std;
int main()
{
printf("Hello World!");
return 0;
}
1000๋ฒ- A+B, 2558๋ฒ - A+B2
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
cout << a + b << endl;
return 0;
}
10950๋ฒ - A+B3
#include <iostream>
using namespace std;
int main()
{
int T;
cin >> T;
while (T--)
{
int a, b;
cin >> a >> b;
cout << a + b << endl;
}
return 0;
}
10951๋ฒ - A+B4
#include <iostream>
using namespace std;
int main()
{
int a, b;
while (cin >> a >> b) cout << a + b << endl;
return 0;
}
10952๋ฒ - A+B5
#include <iostream>
using namespace std;
int main()
{
while (1)
{
int a, b;
cin >> a >> b;
if (a == 0 && b == 0) break;
else cout << a + b << endl;
}
return 0;
}
10953๋ฒ - A+B6
#include <iostream>
using namespace std;
int main()
{
int T;
cin >> T;
for(int i = 0 ; i < T ; i++)
{
int a=0, b=0;
char c;
cin >> a >> c >> b;
if (a + b == 0) break;
else cout << a + b << endl;
}
return 0;
}
11021๋ฒ - A+B7
#include <iostream>
using namespace std;
int main()
{
int T;
cin >> T;
for (int i = 0; i < T; i++)
{
int a, b;
cin >> a >> b;
cout << "Case #" << i + 1 << ": " << a + b << endl;
}
return 0;
}
11022๋ฒ - A+B8
#include <iostream>
using namespace std;
int main()
{
int T;
cin >> T;
for (int i = 0; i < T; i++)
{
int a, b;
cin >> a >> b;
cout << "Case #" << i + 1 << ": " << a <<" + " << b << " = " << a + b << endl;
}
return 0;
}
11718,11719๋ฒ โ ๊ทธ๋๋ก ์ถ๋ ฅํ๊ธฐ
#include <iostream>
#include <string>
using namespace std;
int main()
{
int T;
string t;
while (getline(cin,t)) cout << t << endl;
return 0;
}
11720๋ฒ โ ์ซ์์ ํฉ
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N,sum=0;
string s;
cin >> N >> s;
for (int i = 0; i < N; i++) sum += s.at(i) - '0';
cout << sum << endl;
return 0;
}
11721๋ฒ โ ์ด๊ฐ์ฉ ๋์ด ์ถ๋ ฅํ๊ธฐ
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
int p = 0;
getline(cin, s);
while (p < s.length())
{
cout << s.substr(p, 10) << endl;
p += 10;
}
return 0;
}
2741๋ฒ โ N ์ฐ๊ธฐ
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N,m=1;
cin >> N;
while (m <= N)
printf("%d\n", m++);
return 0;
}
2742๋ฒ - ๊ธฐ์ฐ N
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
cin >> N;
while (N--)
printf("%d\n", N+1);
return 0;
}
2739๋ฒ โ ๊ตฌ๊ตฌ๋จ
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 1; i <= 9; i++)
cout << N << " * " << i << " = " << N * i << endl;
return 0;
}
1924๋ฒ โ 2007๋
#include <iostream>
#include <string>
using namespace std;
string days[] = {"MON","TUE", "WED", "THU", "FRI", "SAT", "SUN"};
int lastdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
int m, d, answer=0;
cin >> m >> d;
for (int i = 0 ; i < m-1; i++) answer += lastdays[i];
answer += d;
if ((answer % 7) - 1 < 0) answer = 6;
else answer = (answer % 7) - 1;
cout << days[answer] << endl;
return 0;
}
8393๋ฒ โ ํฉ
#include <iostream>
using namespace std;
int main()
{
int n;
long long ret = 0;
cin >> n;
for (int i = 1; i <= n ; i++) ret += i;
cout << ret << endl;
return 0;
}
10818๋ฒ โ ์ต์, ์ต๋
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
long long N, low= 1000001, high= -1000001;
vector<long long> v;
cin >> N;
for(long long i = 0 ; i < N ; i++)
{
long long t;
cin >> t;
v.push_back(t);
}
for (long long i = 0; i < N; i++)
{
if (!v.empty())
{
low = min(low, v[i]);
high = max(high, v[i]);
}
}
cout << low << " " << high << endl;
return 0;
}
2438๋ฒ โ ๋ณ์ฐ๊ธฐ1
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j <= i; j++) cout << "*";
cout << endl;
}
return 0;
}
2439๋ฒ โ ๋ณ์ฐ๊ธฐ2
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 1; i <= N; i++)
{
for (int j = N - i; j > 0; j--) cout << " ";
for (int j = 0; j < i; j++) cout << "*";
cout << endl;
}
return 0;
}
2440๋ฒ โ ๋ณ์ฐ๊ธฐ3
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 1; i <= N; i++)
{
for (int j = N - i; j >= 0; j--) cout << "*";
cout << endl;
}
return 0;
}
2441๋ฒ โ ๋ณ์ฐ๊ธฐ4
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < i; j++) cout << " ";
for (int j = N-i ; j >0 ; j--) cout << "*";
cout << endl;
}
return 0;
}
2442๋ฒ โ ๋ณ์ฐ๊ธฐ5
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N - i - 1; j++) cout << " ";
for (int j = 0; j < i * 2 + 1; j++) cout << "*";
cout << endl;
}
return 0;
}
2445๋ฒ โ ๋ณ์ฐ๊ธฐ8
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = -(N-1) ; i < N ; i++)
{
for (int j = 0; j < N - abs(i); j++) cout << "*";
for (int j = 0; j < abs(i)*2; j++) cout << " ";
for (int j = 0; j < N - abs(i); j++) cout << "*";
cout << endl;
}
return 0;
}
2522๋ฒ โ ๋ณ์ฐ๊ธฐ12
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = -(N-1) ; i < N ; i++)
{
for (int j = 0; j < abs(i); j++) cout << " ";
for (int j = 0; j < N - abs(i); j++) cout << "*";
cout << endl;
}
return 0;
}
2446๋ฒ โ ๋ณ์ฐ๊ธฐ9
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = -(N-1) ; i < N ; i++)
{
for (int j = 0; j < N - abs(i) -1 ; j++) cout << " ";
for (int j = 0; j < abs(i)*2+1; j++) cout << "*";
cout << endl;
}
return 0;
}
10991๋ฒ โ ๋ณ์ฐ๊ธฐ16
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 1; i <= N; i++)
{
for (int j = 0; j < (N - i); j++) cout << " ";
for (int j = (N - i); j < N; j++)
{
cout << "*" << " ";
}
cout << endl;
}
return 0;
}
10992๋ฒ โ ๋ณ์ฐ๊ธฐ17
#include <iostream>
using namespace std;
int main()
{
int N;
cin >> N;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N - i - 1; j++) cout << " ";
if (i == (N - 1))
{
for (int j = 0; j < i * 2 + 1; j++) cout << "*";
}
else
{
for (int j = 0; j < i * 2 + 1; j++)
{
if (j == 0 || j == (i * 2)) cout << "*";
else cout << " ";
}
}
cout << endl;
}
return 0;
}
'๐ค PS(Problem Solving) > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 9095๋ฒ - 1, 2, 3 ๋ํ๊ธฐ (0) | 2019.07.03 |
---|---|
[๋ฐฑ์ค] 11727๋ฒ - 2รn ํ์ผ๋ง2 (0) | 2019.07.01 |
[๋ฐฑ์ค] 11726๋ฒ - 2รn ํ์ผ๋ง (0) | 2019.07.01 |
[๋ฐฑ์ค] 1463๋ฒ - 1๋ก ๋ง๋ค๊ธฐ (0) | 2019.06.30 |
[๋ฐฑ์ค] 1058๋ฒ - ์น๊ตฌ (0) | 2019.06.28 |