十六进制数转换成十进制数的函数(C语言)
沈阳理工大学课程设计专用纸
课程设计任务书
学 院 信息科学与
学院 专 业 电子信息科学与技术 学 生 姓 名 张亚辉 学 号 1003070225 设 计 题 目 编程技术基础实训
内容及要求:
利用C语言编写下题的代码。
题目名称:设计将十六进制数转换成十进制数的函数和员工信息管理程序。
内容及要求:
1、十六进制转换成十进制数:写一个函数,输入一个十六进制数,输出相应的十进制数。 。
软件开发环境
Windows XP,TC2.0或Visual C++ 6.0
进度安排:
第18周:
1(算法设计
2(编写程序代码
3(调试程序
4(答辩、验收程序
指导教师(签字): 学院院长(签字):
年 月 日 年 月 日 of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学课程设计专用纸
目 录
一、题目要求 ................................................................................................1 二、算法设计 ................................................................................................2 三、编程实现 ................................................................................................2 四、结果分析 ................................................................................................3 五、参考文献 ................................................................................................5
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学课程设计专用纸
No. 1
一、题目要求
题目名称:设计将十六进制数转换成十进制数的函数和员工信息管理程序。
内容:
1、十六进制转换成十进制数:写一个函数,输入一个十六进制数,输出相应的十进制
数。
要求:
利用C语言编写上述程序,开发环境可采用Turbo C 2.0 或Visual C++ 6.0等。
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学
二、算法设计
1、十六进制转换成十进制数:写一个函数,输入一个十六进制数,输出相应的十进制数。
(1)把输入的十六进制数看成一个数组(char s[N]),十六进制各个位的字符代为相应数组的元素(s[i])。
(2)写出主函数通过调用将十六进制数转为十进制数的函数(fun),实现将十六进制数转为十进制数。
(3)程序
图如下图1
开始
输入十六进制数字符串s[N]
S[i]是否大于10
t=s[i]-‘a’+10 t=s[i]-‘0’
sum=sum*16+t
i=0,i++
i<=N?
输出十进制结果sum
结束
程序流程图1
三、编程实现
程序的具体C语言代码如下:
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学课程设计专用纸
No. 3
第1题:
#include
long fun(char*s); #define N 50
void main()
{
long m;
char s[N];
printf("输入十六进制数:");
scanf("%s",s);
m=fun(s);
printf("十进制数为:%ld",m); }
long fun(char*s)
{
int i,t;
long sum=0;
for(i=0;s[i];i++)
{
if(s[i]<='9')t=s[i]-'0';
else t=s[i]-'a'+10;
sum=sum*16+t;
}
return sum;
}
四、结果分析
第1题:
程序运行结果如图1:
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学
图1 程序运行结果1
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学课程设计专用纸
No. 5
五、参考文献
[1]马秀丽,刘志妩,李筠.C语言程序设计.北京:清华大学出版社,2008
[2]谭浩强.C程序设计(第2版).北京:清华大学出版社,2004
of leadership, along with 500-1000 punishment. (5) significant near miss should be attempted as the case of responsible for the accident and construction team injuries accident penalty provisions, mutatis mutandis. Eight, should perform in the construction standards and specifications, serial number a 1 GB3323-2005 steel fusion welded butt joints, welding engineering-Ray lighting and quality rating of 2 GB11345-89 steel welds manual methods of ultrasonic inspection and testing results for grade 3 GB50236-2002 industrial pipe welding engineering code for construction and acceptance of field equipment 4 HGJ222-92 technical specification for welding of aluminium and its alloys 5 low temperature steel welding procedure 6 SH3525-2004 petrochemical JB/ T4708-2000 of welding procedure qualification for steel pressure vessels 7 JB/4709-2000 8 JB4730-2005 pressure vessel welding procedures of steel pressure vessel NDT 9 JB/T4744-2000 steel pressure vessel products mechanical properties test of welded plate II, mechanical equipment installation engineering 1 GB150-98 2 GB50128-2005 vertical cylindrical steel pressure vessel steel welded specification for construction and acceptance of oil tank 3 JB/ T4735-1997 steel welded atmospheric pressure vessel 4 GB50231-2009 mechanical equipment installation engineering construction and acceptance specification for 5 GB50275-98 compressor, fan and pump installation engineering construction and acceptance specification for lifting 6 HG20201-2000 construction installation engineering construction standard 7, HG ... Pressure gauges, using an installed spark arrestor for acetylene cylinders, illegal carrying, using gas cylinders, each operator fined 20 Yuan. Gas bottle without the hot
沈阳理工大学