본문 바로가기
반응형

백준34

백준 알고리즘 4344번 평균은 넘겠지 c++ 요약 : 케이스 입력 후 학생의 수를 입력하고, 그 학생들의 점수를 입력, 평균보다 높은 점수를 획득한 사람은 몇명이나 있는지 %로 출력한다. 소스코드 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 #include #include using namespace std; int main(void) { int C; cin >> C; while(C--) { int array[1000] = {0,}; float c,k=0; int result=0; cin >> c; for(int i=0;i> array[i]; result += array[i]; } float average = result/c; for(int i=0;i 2021. 1. 20.
백준 알고리즘 8958번 OX퀴즈 c++ 요약 : 케이스 값 입력 후 케이스 수만큼 O와X를 번갈아가면서 넣는다. O가 연속으로 있을시에는 중복으로 1점씩 추가하고, X가 나오면 다시 O가 1점으로 바뀐다. 소스코드 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 #include #include using namespace std; int main(void) { int C; cin >> C; while(C--) { int count = 0,result = 0; char array[81] = {0,}; cin >> array; for(int i=0;i 2021. 1. 20.
백준 알고리즘 1546번 평균 c++ 요약 : 케이스 값 입력 후 값만큼 성적 입력, 모든 점수를 (점수/최고점)*100 로 바꾼다음 평균을 출력한다. 소스코드 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 #include #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int C,num; float result = 0,array[1000] = {0,}; int max = -1; cin >> C; for(int i=0;i> num; array[i] = num; if(max 2020. 12. 13.
백준 알고리즘 3052번 나머지 c++ 요약 : 10개의 값을 입력받은 후 42로 나누었을때 나머지가 다른 값들이 몇개가 나오는지 확인하는 프로그램 소스코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #include using namespace std; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int C = 10,num,result=0; int array[43] = {0,}; for(int i=0;i> num; array[num%42]++; } for(int i=0;i 2020. 12. 13.
백준 알고리즘 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.
반응형