반응형 개인공부/Algorithm(C, C++)12 SW Expert Academy(2058. 자릿수 더하기) C++ #include using namespace std; int main(int argc, char** argv) { int N; int sum = 0; int value = 1000; cin>>N; for( ; value > 0 ;) { sum += N / value; N %= value; value /= 10; } printf("%d", sum ); return 0;//정상종료시 반드시 0을 리턴해야합니다. } 1. 자리수가 최대 4자리 수라 value를 1000으로 고정했다. 2021. 8. 10. SW Expert Academy(2063. 중간값 찾기) C++ #include #include using namespace std; int main(int argc, char** argv) { int test_case; int T; int a[199]; cin>>T; for(test_case = 0; test_case > a[test_case]; } sort(a, a+199); printf("%d", a[T/2]); return 0;//정상종료시 반드시 0을 리턴해야합니다. } 2021. 8. 10. SW Expert Academy(2068. 최대수 구하기) C++ #include using namespace std; int main(int argc, char** argv) { int test_case; int T; int a[10]; int max; cin>>T; for(test_case = 1; test_case a[k]; if(a[k] > max) max = a[k]; } printf("#%d %d\n", test_case, max); } return 0;//정상종료시 반드시 0을 리턴해야합니다. } 2021. 8. 10. SW Expert Academy (2070. 큰 놈, 작은 놈, 같은 놈)C++ #include #include using namespace std; int main(int argc, char** argv) { int test_case; int T; int a, b; cin>>T; for(test_case = 1; test_case b) printf("#%d >\n", test_case); else if( a == b) printf("#%d =\n", test_case); else printf("#%d 2021. 8. 9. 이전 1 2 3 다음 반응형