1、2.The Structure of Design2.1 Operation platform and development environmentThis procedure is in the Microsoft Visual C+ software platform has compiled, integrated development environment, can provide the editor C language, C+ and C+/CLI programming language.The integration of VC+ convenient debuggin
2、g tools, especially the integration of the Microsoft Windows programming (Windows API), 3D animation DirectX API, Microsoft.NET framework.2.2 System structureAbove the synthesis analysis and development features of the platform, I decided to adopt the structure of data structure, the bearing design
3、for basic information data structure data, used to store multiple bearing information, the bearing inside diameter, outside diameter, width of models, such as data as the members of the structure, so as to realize the correspondence between the input and output of information.Figure 2-13.Program3.1
4、Flow chartImplementation of this function is mainly uses the switch statement.The first printf function in the operation of the interface type bearing inquiry system and functional module and its corresponding digital option.Then enter the operations to be performed by the switch statement options,
5、judge, and then into the different functions, different operation.Of course, to after an operation to call the menu function, is convenient for users to carry out an operation line.3.2 The contents of the programVC+6.0 environment compilerFigure 3-1Detailed C language program as follows#define N 100
6、#include /*头文件*/string.hstdlib.hstruct bearing /*数据结构定义*/ char num5; /*轴承型号*/ char d14; /*内径*/ char d24; /*外径*/ char b4; /*宽度*/ char da14; /*damin*/ char da24; /*Damax*/ char cr5; /*基本额定静载荷/kN*/ char nr6; /*极限转速/(r/min)油润滑*/bearingsN;void printf_face() /*表头函数*/ printf(轴承型号 内径 外径 宽度 damin Damax 基本额定静
7、载荷/kN 极限转速/(r/min)油润滑n);/*输入模块*/void enter() int i,n; /*i是for循环里的循环变量。n是轴承的数目*/ void menu(); /*申明主函数*/ void input(int k); /*申明输入函数*/ void save(int k); /*申明保存函数*/要输入的轴承数量:,N-1); scanf(%d,&n); /*要输入轴承信息的数目*/n输入轴承信息资料nn for(i=0;in;i+) n 输入第%d个轴承信息资料.n,i+1); input(i); /*输入函数*/ if(i!=0)save(n); /*保存函数*/按
8、任何键返回n getchar(); /*返回*/ menu();void input(int i) /*输入函数*/ printf_face();%s%s%s%s%s%s%s%s,bearingsi.num,bearingsi.d1,bearingsi.d2,bearingsi.b,bearingsi.da1,bearingsi.da2,bearingsi.cr,bearingsi.nr);void save(int n) /*保存函数*/ FILE *fp; int i; if(fp=fopen(bearing.txt,wb)=NULL)未录入此型号轴承n if(fwrite(&bearin
9、gsi,sizeof(struct bearing),1,fp)!=1)输入错误n fclose(fp);/*浏览模块*/void browse() int k; /*表示文件中有k种轴承*/ int load(); /*申明打开文件函数*/ void printf_bearings(int n); /*申明输出函数(包含表头)*/ k=load(); printf_bearings(k); /*输出k种轴承信息(包含表头)*/void printf_one(int i) /*输出函数*/printf(%5s %5s %5s %5s %5s %5s %5s %5snnvoid printf_b
10、earings(int n) /*输出函数(包含表头)*/ int j; for(j=0;jj+) printf_one(j);int load() /*打开文件函数*/ rbn未录入此型号轴承n return 0;!feof(fp); fread(&bearingsi,sizeof(struct bearing),1,fp); return(i-1);void search_by_d1() struct bearing s; int n,i,k=0; void printf_one(int i); n=load();请输入内径: %ss.d1);printf_face(); if(strcmp(s.d1,bearingsi.d1)=0) printf_one(i); k=1; if(k=0)printf(n未录入此型号轴承!nvoid search_by_d2()请输入外径:s.d2); if(strcmp(s.d2,bearingsi.d2)=0)void search_by_num()请输入轴承型号:s.num);printf
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1