当前位置:网站首页>[pointer] octal to decimal
[pointer] octal to decimal
2022-07-06 14:36:00 【|Light|】
requirement
Make up a function , Realize octal conversion to decimal .( Use a pointer to achieve )
Code
/* * This function is used to convert an octal number to a decimal number * Octal numbers are stored in formal parameters as strings a In the one-dimensional character array pointed to * Please return the calculated decimal number as a function value */
int oct_to_dec(char* a)
{
int d=0;
int i;
int k=strlen(a)-1;
for(i=0;i<20;i++)
{
if(a[i]=='\0')
{
break;
}
else
{
d = d + ((a[i]-48)*pow(8,k));
k--;
}
}
return d;
}
main function
int main()
{
char a[20];
int n;
gets(a);
n = oct_to_dec(a);
printf("%d",n);
return 0;
}
test
Test input
1234
Output
668
边栏推荐
- 关于超星脚本出现乱码问题
- JDBC看这篇就够了
- [paper reproduction] cyclegan (based on pytorch framework) {unfinished}
- Proceedingjoinpoint API use
- Realize applet payment function with applet cloud development (including source code)
- 内网渗透之内网信息收集(四)
- Wu Enda's latest interview! Data centric reasons
- Solutions to common problems in database development such as MySQL
- Attack and defense world misc practice area (simplerar, base64stego, no matter how high your Kung Fu is, you are afraid of kitchen knives)
- Constants, variables, and operators of SystemVerilog usage
猜你喜欢

《统计学》第八版贾俊平第六章统计量及抽样分布知识点总结及课后习题答案

Database monitoring SQL execution

sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现

SystemVerilog discusses loop loop structure and built-in loop variable I

《统计学》第八版贾俊平第二章课后习题及答案总结

Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class

Hcip -- MPLS experiment

Intel oneapi - opening a new era of heterogeneity

Circular queue (C language)

《统计学》第八版贾俊平第三章课后习题及答案总结
随机推荐
Binary search tree concept
Detailed explanation of network foundation routing
Numpy Quick Start Guide
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
List and data frame of R language experiment III
Hackmyvm target series (2) -warrior
Numpy快速上手指南
2022华中杯数学建模思路
This article explains in detail how mockmvc is used in practical work
MSF generate payload Encyclopedia
Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
函数:用牛顿迭代法求方程的根
Xray and burp linkage mining
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
5分钟掌握机器学习鸢尾花逻辑回归分类
JDBC看这篇就够了
{1,2,3,2,5}查重问题
【指针】求二维数组中最大元素的值
Sentinel overall workflow
Matplotlib绘图快速入门