Question 1020: octal Digit

Source: Internet
Author: User

The Title Description converts the decimal number to octal and outputs the result. Figure: Convert the decimal number to octal and the output input contains several decimal positive integers. Output the corresponding Octal numbers, each of which occupies one row. Sample input 1237891910020345 sample output 123710112346162771 prompt [+] *** prompt hidden, click [+] at the top to display the *** source data structure algorithm teaching question -- Zhang Feifei [cpp]/******************* * **************** Date: * Author: SJF0115 * question: tianqin OJ question 1020: algorithm 3-1: octal number * Source: http://acmclub.com/problem.php? Id = 1020 * result: AC * Source: Data Structure algorithm teaching question -- Zhang Feifei * Summary: * *********************************/# include <stdio. h >#include <iostream >#include <stack> using namespace std; # define MAXSIZE 1000 // input string char str [MAXSIZE]; // convert the 10th hexadecimal form to B (stack) void Conversion (int num, int B) {stack <int> S; // except B for the remainder do {// the remainder is stored in stack S. push (num % B); num/= B;} while (num); // output while (! S. empty () {printf ("% d", S. top (); S. pop () ;}printf ("\ n") ;}int main () {int a, B; while (scanf ("% d", & )! = EOF) {B = 8; // convert the decimal format to the octal Conversion (a, B);} return 0 ;} /********************************** Date: * Author: SJF0115 * question: tianqin OJ question 1020: algorithm 3-1: octal number * Source: http://acmclub.com/problem.php? Id = 1020 * result: AC * Source: Data Structure algorithm teaching question -- Zhang Feifei * Summary: * *********************************/# include <stdio. h >#include <iostream >#include <stack> using namespace std; # define MAXSIZE 1000 // input string char str [MAXSIZE]; // convert the 10th hexadecimal form to B (stack) void Conversion (int num, int B) {stack <int> S; // except B for the remainder do {// the remainder is stored in stack S. push (num % B); num/= B;} while (num); // output while (! S. empty () {printf ("% d", S. top (); S. pop () ;}printf ("\ n") ;}int main () {int a, B; while (scanf ("% d", & )! = EOF) {B = 8; // convert the decimal format to the octal Conversion (a, B);} return 0 ;}

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.