PAT Basic 1086 will not tell you (15 points)

Homework time, sitting next Xiaopen friends ask you: "Five multiplied by seven equals how many?" You should be polite to enclose smiled and told him:. "Fifty-three" This question requires you, for any pair given positive integer, output their product backwards.

53.jpg

Input formats:

Given two input positive integer not more than 1000 A and B in the first row, separated by a space therebetween.

Output formats:

Backwards in row A and B outputs the product.

Sample input:

5 7

Sample output:

53


#include <iostream>
using namespace std;
int main(){
    int a,b,tmp;string res="";
    cin>>a>>b;
    int val=a*b;
    while(val!=0){
        res+=(val%10+'0');
        val/=10;
    }
    for(int i=0;i<res.length();i++){
        if(res[i]!='0') {
            tmp=i;
            break;
        }
    }
    cout<<res.substr(tmp,res.length()-tmp);
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/littlepage/p/11361495.html