C语言课程设计-十六进制转换为十进制.doc
Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-dateC语言课程设计-十六进制转换为十进制C语言课程设计“十六进制转换为十进制”C语言课程设计“十六进制转换为十进制”-附带源文件一、课程设计内容用C语言编写软件完成以下任务:给小学生出算术题:不超过三位数的算术加减法,即,进行加减运算的两个整数不超过三位数,加减运算的结果也不超过三位数。小学生见考题后输入结果,若小学生回答正确,程序显示“正确”,否则显示“错误”。二、课程设计要求程序质量:² 贯彻结构化的程序设计思想。² 用户界面友好,功能明确,操作方便。² 至少有“开始出题”、“退出”2项。² 代码应适当缩进,并给出必要的注释,以增强程序的可读性。课程设计说明书:² 课程结束后,上交课程设计说明书和源程序。课程设计说明书的内容参见提供的模板。源文件:#include<stdio.h>#include<conio.h>#include<string.h>#define N 1000char strN;int aN,bN;void menu() puts("1.输入一个十六进制的数"); puts("2.开始转换"); puts("3.退出");void zsh() int i,j; j=strlen(str)-1; bj=1; for(i=j;i>0;i-) bi-1=bi*16; long ycl() long x,i,j; j=strlen(str)-1; for(x=0,i=j;i>=0;i-) if(stri>='a'&&stri<='f') ai=stri-'a'+10; else if(stri>='A'&&stri<='F') ai=stri-'A'+10; else ai=stri-'0' x=x+ai*bi; return x; void math() int i,n; do printf("请输入一个十六进制数:n"); scanf("%s",str); for(i=0,n=0;stri!='0'i+) if(stri<'0'|(stri>'9'&&stri<'A')|(stri>'F'&&stri<'a')|stri>'f') n=1; printf("输入不符和要求n"); break; while(n); zsh(); getch(); void print()int m;m=ycl();printf("转换成十进制后的结果为%ldn",m);void main()char choice;menu();choice=getch();while(1)switch(choice)case '1':math();break;case '2': print();break;case '3':return;choice=getch();-