46: octal to decimal, 46-decimal

Source: Internet
Author: User

46: octal to decimal, 46-decimal
46: octal to decimal

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

Converts an octal positive integer to a decimal number.

Input
A row contains only one positive integer a represented by octal. The range of a in decimal format is (0, 65536 ).
Output
A row in decimal format.
Sample Input
11
Sample output
9

 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<cmath> 5 using namespace std; 6 int ans[10001]; 7 int now; 8 int tot; 9 int j=1;10 int main() 11 {12     int n;13     cin>>n;14     while(n!=0)15     {16         tot=n%10*j+tot;17         j=j*8;18         n=n/10;19     }20     cout<<tot;21     return 0;22 }

 

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.