본문 바로가기
반응형

category/백준 알고리즘 c++42

백준 알고리즘 2577번 숫자의 개수 c++ 요약 : A B C의 값을 입력 후 세 수를 곱하고, 그 결과의 가 자릿수마다 쓰인 0~9까지 숫자가 몇번 쓰였는지 출력하는 프로그램 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int A,B,C,num[11]={0}; cin >> A >> B >> C; string s = to_string(A*B*C); //A*B*C의 값을 문자열로 바꾼다. for(int i=0;i 2020. 12. 13.
백준 알고리즘 2562번 최대 c++ 요약 : 9개의 자연수를 입력 후 최댓값 과 최댓값의 순서 출력 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int array[9] = {0,},num=0; int max=-100000001; for(int i=0;i> array[i]; if(max 2020. 12. 13.
백준 알고리즘 10818번 최소, 최대 c++ 요약 : CASE값을 받고 CASE만큼 값 입력 후 최솟값과 최댓값을 순서대로 출력 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include #include using namespace std; //sort를 쓰면 더 느리게 풀리지만, 귀찮아서 그냥 sort사용 ㅎㅎ; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int C; cin >> C; int array[C] = {0,}; for(int i=0;i> array[i]; } sort(array,array+C); cout 2020. 12. 13.
백준 알고리즘 1110번 더하기 사이클 c++ 요약 : N입력 후 N의 둘째 자리 -> 첫 자리로, N의 첫 자리 + N의 둘째 자리 -> 둘째 자리로 (10 이상이면 둘째자리만 옮긴다.) 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a,b,swap,count=1; cin >> a; swap = a; if(a/10 + a%10 >= 10) b=(a/10+a%10)%10; else b=a/10 + a%10; a = (a%10)*10 + b; while(swap!=a) .. 2020. 12. 4.
백준 알고리즘 10951번 A + B - 4 c++ 요약 : A와 B 입력 후 A+B의 값을 출력한다. 프로그램을 끝내는 조건문이 없으므로 while()에 조건문을 걸어두자. 소스코드 1. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a,b; while(cin >> a >> b) { cout b; if(cin.eof()==true) break; //입력값이 없을 때 cout 2020. 12. 4.
백준 알고리즘 10952번 A + B - 5 c++ 요약 : A와 B 입력 후 0 0이 입력되기 전까지 A+B의 값을 출력한다. 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a,b; while(true) { cin >> a >> b; if(a==0&&b==0) break; cout 2020. 12. 4.
백준 알고리즘 10871번 X보다 작은 수 c++ 요약 : N과 X의 값 입력 후 X보다 작은 정수를 출력한다. 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int C,num; int a; cin >> C >> num; for(int i=0;i> a; if(num > a) cout 2020. 12. 4.
백준 알고리즘 2439번 별 찍기 - 2 c++ 요약 : N 입력 후 해당 값만큼 직각 삼각형 모양으로 별을 찍는다. 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; for(int i=1;i 2020. 12. 4.
백준 알고리즘 2438번 별 찍기 - 1 c++ 요약 : N입력 후 해당 값만큼 직각 삼각형 모양으로 별을 찍는다. 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; for(int i=1;i 2020. 12. 4.
반응형