第2章 CADCAM技术基础-工程数据的计算机处理2011.pptVIP

  • 3
  • 0
  • 约8.39千字
  • 约 46页
  • 2017-09-10 发布于浙江
  • 举报

第2章 CADCAM技术基础-工程数据的计算机处理2011.ppt

第2章 CADCAM技术基础-工程数据的计算机处理2011

第一章 绪论 引 例 引 例 内 容 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 C语言相关知识: #include “stdio.h” //包含“standard inputoutput”头文件 void main(void) { //主程序; } 常用数据类型:int(整型)、float(浮点数)等; 数组:a[ ],b[ ][ ],c[ ][ ][ ]; 常用函数:scanf(“ ”)输入、输出printf (“ ”)、for循环、if( )条件判断。 参考教材:《C语言程序设计教程(第3版)》谭浩强主编 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 #include “stdio.h” void main(void) { int i, j;float w, t;/* 定义用户输入的料厚、料宽变量*/ float Width [6]={40,50,70,90,120,150};/*定义表格中的料厚(一维数组),并初始化赋值*/ float Thick [4]={0.8,1.5,3.0,5.0};/*定义表格中的料宽(一维数组),并初始化赋值 */ float Distance[6][4]={{22,24,28,32},{24,27,31,35},{30,33,36,40}, {36,39,42,46}, 40,45,48,52}, {44,48,52,55}}; /*定义距离值(二维数组),并初始化赋值*/ printf(please input width of material: w= \n); scanf(%f,w); /* 输入料宽值 */ printf(please input thick of material: t= \n); scanf(%f,t); /* 输入料厚值 */ for (i=0; i6; i++) if(w = Width[i]) break; for (j=0; j4; j++) if(t = Thick[j]) break; printf(The distance between the cutting edge and margin of female die, or between the cutting edge of female die: %\f, Distance[i][j]); /* 输出距离值 */ } 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 2.1 工程数据的程序化处理 内 容 2.2 工程数据的文件化处理 2.2 工程数据的文件化处理 2.2 工程数据的文件化处理 2.2 工程数据的文件化处理 #include “stdio.h” #define num=# # # ;;; /* # # #按实际记录赋值 */ struct key_GB {float d1,d2,b,h,t,t1; } key; /* 定义键元素(结构体) */ void main() { int i; FILE *fp; if((fp=fopen(“key.dat”, “w”))==NULL) /* 打开文件key.dat, 用于写入 */ { printf(“Can’t open the data file”); exit(); } for(i=0;inum;i++) { printf(“record/%d:d1,d2,b,h,t,t1=”,i); scanf(%f, %f , %f , %f , %f ,%f ”,key.d1, key.d2, key.b, key.h, key.t,key.t1); /* 输入各记录数据项 */ fwrite(key,sizeof(struct key_GB,1,fp) /*写入各记录数据项于文件中 */ } fclose(fp); } 2.2 工程数据的文件化处理 #include “stdio.h” #define num=# # # ;;; /* # # # 按实际记录赋值 */ struct key_GB {float d1,d2,b,h,t,t1; } key; void main() { in

文档评论(0)

1亿VIP精品文档

相关文档