목록C, C++ 문제풀이 (39)
rueki
www.acmicpc.net/problem/1357 1357번: 뒤집힌 덧셈 어떤 수 X가 주어졌을 때, X의 모든 자리수가 역순이 된 수를 얻을 수 있다. Rev(X)를 X의 모든 자리수를 역순으로 만드는 함수라고 하자. 예를 들어, X=123일 때, Rev(X) = 321이다. 그리고, X=100일 때, Rev( www.acmicpc.net #include #include #include using namespace std; int Rev(string str) { reverse(str.begin(), str.end()); int result = stoi(str); return result; } int main() { string a, b; cin >> a >> b; int res = Rev(a) + ..
www.acmicpc.net/problem/1681 1681번: 줄 세우기 민승이는 가장 작은 10개의 수 2, 3, 4, 5, 6, 7, 8, 9, 20, 22를 사용하여 라벨을 붙일 수 있다. www.acmicpc.net #include #include using namespace std; int main() { int n, num = 0; char l; cin >> n >> l; //1부터 10 까지 for (int i = 0; i < n; ++i) // 매 숫자마자 ㅣ이 포함되어있는지 찾고 아닌 경우 npos 반환 while (to_string(++num).find(l) != string::npos); cout
www.acmicpc.net/problem/1427 1427번: 소트인사이드 첫째 줄에 정렬하고자하는 수 N이 주어진다. N은 1,000,000,000보다 작거나 같은 자연수이다. www.acmicpc.net #include #include #include using namespace std; int main() { char arr[10]; cin >> arr; sort(arr, arr + strlen(arr), greater()); for (int i = 0; i < strlen(arr); i++) { cout
www.acmicpc.net/problem/2908 2908번: 상수 상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두 www.acmicpc.net #include #include #include #include using namespace std; int main() { string n1, n2; cin >> n1 >> n2; reverse(n1.begin(), n1.end()); reverse(n2.begin(), n2.end()); int r_n1 = stoi(n1); int r_n2 = stoi(n2); int result = max(r_n1, r_n2); cout