Blue Bridge Cup ALGO-93 inverse number (math, function)

Source: Internet
Author: User

"Ideas": Use of Atoi and itoa, note atoi, three parameters. The first one is the number to convert, the second is the one that is stored in that string, and the third is what the binary is.

"AC Code":

#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include < cstring>using namespace std; #define MAX 20+2int reverse_num (int x) {int i = 0;char A[max];itoa (x, A, ten); for (i = 0; I & Lt Strlen (a)/2; i++) {Char temp = a[i];a[i] = A[strlen (a) -1-i];a[strlen (a) -1-i] = temp;} Return Atoi (a);} int main () {//freopen ("In.txt", "R", stdin); int i = 0, sum = 0;int A = 0, b = 0;; Cin >> a >> b;int m = Reverse_num (a), int n = reverse_num (b); sum = m + n;cout << reverse_num (sum);}



Blue Bridge Cup ALGO-93 inverse number (math, function)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.