当前位置:网站首页>[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
边栏推荐
- Constants, variables, and operators of SystemVerilog usage
- 《统计学》第八版贾俊平第七章知识点总结及课后习题答案
- 《统计学》第八版贾俊平第五章概率与概率分布
- Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
- 【指针】删除字符串s中的所有空格
- 《統計學》第八版賈俊平第七章知識點總結及課後習題答案
- 【指针】使用插入排序法将n个数从小到大进行排列
- 2022华中杯数学建模思路
- Windows platform mongodb database installation
- 我的第一篇博客
猜你喜欢
数字电路基础(一)数制与码制
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?
Wu Enda's latest interview! Data centric reasons
数字电路基础(四) 数据分配器、数据选择器和数值比较器
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
How to earn the first pot of gold in CSDN (we are all creators)
循环队列(C语言)
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
DVWA (5th week)
JDBC read this article is enough
随机推荐
captcha-killer验证码识别插件
内网渗透之内网信息收集(三)
函数:字符串反序存放
内网渗透之内网信息收集(四)
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
使用 flask_whooshalchemyplus jieba实现flask的全局搜索
This article explains in detail how mockmvc is used in practical work
Xray and Burp linked Mining
List and data frame of R language experiment III
[pointer] counts the number of times one string appears in another string
SQL injection
关于交换a和b的值的四种方法
Fundamentals of digital circuit (V) arithmetic operation circuit
XSS (cross site scripting attack) for security interview
《英特尔 oneAPI—打开异构新纪元》
{1,2,3,2,5}查重问题
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
c语言学习总结(上)(更新中)
What language should I learn from zero foundation. Suggestions
《统计学》第八版贾俊平第十章方差分析知识点总结及课后习题答案