45: decimal to octal, 45 decimal

Source: Internet
Author: User

45: decimal to octal, 45 decimal
45: decimal to octal

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

Converts a decimal positive integer to octal.

Input
A row containing only one decimal integer a (0 <a <65536 ).
Output
One row, which is octal of.
Sample Input
9
Sample output
11
 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 main() 10 {11     int n;12     cin>>n;13     while(n!=0)14     {15         ans[now]=n%8;16         n=n/8;17         now++;18     }19     for(int i=now-1;i>=0;i--)20     cout<<ans[i];21     return 0;22 }

 

Related Article

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.