Wuhan University of Science and Technology acm:1008: Chinese Edition C language Programming tutorial (second edition) Exercise 6.14

Source: Internet
Author: User

Problem Description

Enter an octal string, convert it to an equivalent decimal string, and output it in the PRINGF%s format.

Input

First, a positive integer t is entered, indicating that there is a T set of test data (1<= T <= 10010).

Next T line, one string per line, representing an octal integer (this integer is no more than 20 bits).

Output

For each test data, output the corresponding decimal string. One line per string.

Sample Input
11732
Sample Output
986
HINT

Note: The given octal number may be large, with a long long

#include <stdio.h>#include<string.h>#include<stdlib.h>Long LongMishu (intj) {    Long Longres =1;  for(;j>0; j--) {res*=8; }    returnRes;}intMain () {inti,j,k,m; Long LongN;  while(SCANF ("%d", &m)! =EOF) {         for(k=0; k<m;k++) {n=0; Chars[ +]; scanf ("%s", s);  for(I=strlen (s)-1, j=0; i>=0; I--, J + +) {n+ = (s[i]-'0')*Mishu (j); } printf ("%lld\n", N); }            }        return 1;}

Wuhan University of Science and Technology acm:1008: Chinese Edition C language Programming tutorial (second edition) Exercise 6.14

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.