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://www.codercto.com/courses/l/17.html

查看所有标签

Learning Web App Development

Learning Web App Development

Semmy Purewal / O'Reilly Media / 2014-3-3 / USD 29.99

Grasp the fundamentals of web application development by building a simple database-backed app from scratch, using HTML, JavaScript, and other open source tools. Through hands-on tutorials, this pract......一起来看看 《Learning Web App Development》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具