当前位置:网站首页>[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
边栏推荐
- Get started with Matplotlib drawing
- Intel oneapi - opening a new era of heterogeneity
- 函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
- 《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
- 内网渗透之内网信息收集(二)
- 指针 --按字符串相反次序输出其中的所有字符
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- JDBC read this article is enough
- Intranet information collection of Intranet penetration (3)
- 【指针】统计一字符串在另一个字符串中出现的次数
猜你喜欢
Solutions to common problems in database development such as MySQL
SystemVerilog discusses loop loop structure and built-in loop variable I
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
1.支付系统
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
Based on authorized access, cross host, and permission allocation under sqlserver
Record once, modify password logic vulnerability actual combat
内网渗透之内网信息收集(四)
Xray and burp linkage mining
移植蜂鸟E203内核至达芬奇pro35T【集创芯来RISC-V杯】(一)
随机推荐
The most popular colloquial system explains the base of numbers
Load balancing ribbon of microservices
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
Xray and burp linkage mining
Based on authorized access, cross host, and permission allocation under sqlserver
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
Applet Web Capture -fiddler
内网渗透之内网信息收集(二)
MSF generate payload Encyclopedia
Overview of LNMP architecture and construction of related services
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
Xray and Burp linked Mining
On the idea of vulnerability discovery
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
How to test whether an object is a proxy- How to test if an object is a Proxy?
How does SQLite count the data that meets another condition under the data that has been classified once
数字电路基础(一)数制与码制
Detailed explanation of network foundation routing