C 练习实例82

C 语言教程 · 2019-02-22 14:29:03

题目:八进制转换为十进制

程序分析:无。

编译/执行 C 程序

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include<stdio.h> #include<stdlib.h> int main() { int n=0,i=0; char s[20]; printf("请输入一个8进制数:\n"); gets(s); while(s[i]!='\0'){ n=n*8+s[i]-'0'; i++; } printf("刚输入的8进制数转化为十进制为\n%d\n",n); return 0; }

以上实例运行输出结果为:

请输入一个8进制数:
16
刚输入的8进制数转化为十进制为
14

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Web 2.0 Heroes

Web 2.0 Heroes

Bradley L. Jones / Wiley / 2008-04-14 / USD 24.99

Web 2.0 may be an elusive concept, but one thing is certain: using the Web as merely a means of retrieving and displaying information is history. Today?s Web is immediate, interactive, innovative. It ......一起来看看 《Web 2.0 Heroes》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具