끄적끄적 코딩
article thumbnail
[C++] 백준 11720번 숫자의 합
알고리즘 2019. 3. 5. 13:52

입력된 값들의 숫자를 하나하나 더해서 출력하는 문제입니다. int나 double로 받게 될 경우 범위를 넘는 경우가 생길 수 있어서 string으로 입력을 받았습니다. stoi함수를 이용해서 string을 int로 바꾸고 substr함수로 한 글자씩 잘라서 sum에 추가해주었습니다. #include #include using namespace std; int main(int argc, char * argv[]) { int a; int i = 0; string s; int sum = 0; cin >> a; cin >> s; for (int i = 1; i

article thumbnail
[C++] 백준 8393번 합
알고리즘 2019. 3. 5. 13:31

for문을 이용해서 문제를 풀었습니다. 입력한 값이 될때까지 i를 증가하면서 더합니다. #include #include using namespace std; int main(int argc, char *argv[]) { int x=0, value=0; cin >> x; for(int i=0; i

article thumbnail
[C++] 백준 1924번 2007년
알고리즘 2019. 3. 5. 13:27

month에 월, d에 일을 입력 받습니다. 그리고 d에 month를 day로 변환한값을 더한 후 switch문으로 요일을 판별합니다. #include using namespace std; int main(int argc, char *argv[]) { int m[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int d = 1; int month = 1; cin >> month; cin >> d; for (int i = 0; i < month; ++i) { d += m[i]; } switch (d % 7) { case 0: cout

article thumbnail
[C++] 백준 2441번 별 찍기 - 4
알고리즘 2019. 3. 5. 02:04

2중 for문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; for (int i = 0; i = i) { cout

article thumbnail
[C++] 백준 2440번 별 찍기 - 3
알고리즘 2019. 3. 5. 02:04

2중 for문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; for (int i = 0; i i; j--) { cout

article thumbnail
[C++] 백준 2439번 별 찍기 - 2
알고리즘 2019. 3. 5. 02:02

for문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; for (int i = 2; i 0; j--) { if (j < i) { cout

article thumbnail
[C++] 백준 2438번 별 찍기 - 1
알고리즘 2019. 3. 5. 01:55

for문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; for(int i=1; i

article thumbnail
[C++] 백준 2739번 구구단
알고리즘 2019. 3. 5. 01:44

for문을 이용해서 문제를 풀었습니다. #include using namespace std; int main(int argc, char *argv[]) { int n; cin >> n; for(int i=0; i

검색 태그