5년전에 했던건가?ㅋㅋ 아직도 남아있네
LV 0. 문자열 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181952
#include <iostream>
#include <string>
using namespace std;
int main(void) {
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str;
cin >> str;
cout << str;
return 0;
}
LV 0. a와 b 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181951
#include <iostream>
#include <string>
using namespace std;
void print(string s, int n) {
cout << s << " = " << n << endl;
}
int main(void) {
int a;
int b;
cin >> a >> b;
print("a", a);
print("b", b);
return 0;
}
LV 0. 문자열 반복해서 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181950
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string str;
int n;
cin >> str >> n;
for(int i=0; i<n; ++i) {
cout << str;
}
return 0;
}
LV 0. 대소문자 바꿔서 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181949
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string str; cin >> str;
for(int i=0; i<str.size(); i++) {
char word = str[i];
if (word >= 'a' && word <= 'z') {
str[i] -= 32;
}
else {
str[i] += 32;
}
}
cout << str;
return 0;
}
LV 0. 특수문자 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181948
#include <iostream>
using namespace std;
int main(void) {
cout << R"(!@#$%^&*(\'"<>?:;)";
return 0;
}
LV 0. 덧셈식 출력하기
https://school.programmers.co.kr/learn/courses/30/lessons/181947
#include <iostream>
using namespace std;
int main(void) {
int a;
int b;
cin >> a >> b;
int c = a + b;
cout << a << " + " << b << " = " << c;
return 0;
}
LV 0. 문자열 붙여서 출력하기
이건 어째 문제가좀 이상한데.... 공백문자가 input 으로 들어오던지 해서 파싱을 하던지 해야는데 좀그렇네
https://school.programmers.co.kr/learn/courses/30/lessons/181946
#include <iostream>
#include <string>
using namespace std;
void print(string s) {
for(auto a:s) {
if( a == ' ') {
break;
}
cout << a;
}
}
int main(void) {
string str1, str2;
cin >> str1 >> str2;
print(str1 + str2);
return 0;
}
LV 0. 문자열 돌리기
https://school.programmers.co.kr/learn/courses/30/lessons/181945
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string str;
cin >> str;
for(auto a:str) {
cout << a << endl;
}
return 0;
}
LV 0. 홀짝 구분하기
https://school.programmers.co.kr/learn/courses/30/lessons/181944
#include <iostream>
using namespace std;
int main(void) {
int n;
cin >> n;
if (n & 1) {
cout << n << " is odd";
}
else {
cout << n << " is even";
}
return 0;
}
LV 0. 문자열 겹쳐쓰기
https://school.programmers.co.kr/learn/courses/30/lessons/181943
#include <string>
#include <vector>
using namespace std;
string solution(string my_string, string overwrite_string, int s) {
for (int i = 0; i < overwrite_string.size(); i++) {
my_string[i+s] = overwrite_string[i];
}
return my_string;
}
LV 0. 접두사인지 확인하기
https://school.programmers.co.kr/learn/courses/30/lessons/181906
#include <string>
#include <vector>
using namespace std;
int solution(string my_string, string is_prefix) {
int answer = 0;
if (is_prefix.size() > my_string.size()) {
return 0;
}
for(int i = 0; i < is_prefix.size(); i++) {
if (my_string[i] != is_prefix[i]) {
return 0;
}
}
return 1;
}
LV 0. 카운트 다운
https://school.programmers.co.kr/learn/courses/30/lessons/181899
#include <string>
#include <vector>
using namespace std;
vector<int> solution(int start, int end_num) {
vector<int> answer;
for(int i=start; i >= end_num; --i) {
answer.push_back(i);
}
return answer;
}
LV 0. n 번째 원소부터
https://school.programmers.co.kr/learn/courses/30/lessons/181892
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> num_list, int n) {
vector<int> answer;
for(int i=n-1; i<num_list.size(); i++)
answer.push_back(num_list[i]);
return answer;
}
LV 0. 공배수
https://school.programmers.co.kr/learn/courses/30/lessons/181936
#include <string>
#include <vector>
using namespace std;
int solution(int number, int n, int m) {
if (number % n == 0 && number % m == 0)
return 1;
return 0;
}
LV 0. 문자열 섞기
https://school.programmers.co.kr/learn/courses/30/lessons/181942
#include <string>
#include <vector>
using namespace std;
string solution(string str1, string str2) {
string answer = "";
for(int i=0; i< str1.size(); i++) {
answer+=str1[i];
answer+=str2[i];
}
return answer;
}
LV 0. 문자 리스트를 문자열로 변환하기
https://school.programmers.co.kr/learn/courses/30/lessons/181941
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(vector<string> arr) {
string answer = "";
for(auto s:arr){
answer+=s;
}
return answer;
}
LV 0. 문자열 곱하기
https://school.programmers.co.kr/learn/courses/30/lessons/181940
#include <string>
#include <vector>
using namespace std;
string solution(string my_string, int k) {
string answer = "";
for(int i=0; i<k; i++)
answer += my_string;
return answer;
}
LV 0. n의 배수
https://school.programmers.co.kr/learn/courses/30/lessons/181937
#include <string>
#include <vector>
using namespace std;
int solution(int num, int n) {
if (num % n == 0) {
return 1;
}
return 0;
}
LV 0. 더 크게 합치기
https://school.programmers.co.kr/learn/courses/30/lessons/181939
#include <string>
#include <vector>
using namespace std;
int solution(int a, int b) {
string s1 = to_string(a);
string s2 = to_string(b);
string s3 = s1 + s2;
string s4 = s2 + s1;
if (stoi(s3) > stoi(s4)) {
return stoi(s3);
}
return stoi(s4);
}| algorithm weekly ~ 2022.02.06 (0) | 2022.02.04 |
|---|---|
| Weekly Contest 277 (0) | 2022.01.23 |
| 2033. Minimum Operations to Make a Uni-Value Grid (0) | 2021.10.10 |
| 2032. Two Out of Three (0) | 2021.10.10 |
| 442. Find All Duplicates in an Array (0) | 2021.10.07 |
댓글 영역