当前位置:文档之家› (04) Study on HVOF sprayed nickel coated MoS2 coatings

(04) Study on HVOF sprayed nickel coated MoS2 coatings

(04) Study on HVOF sprayed nickel coated MoS2 coatings
(04) Study on HVOF sprayed nickel coated MoS2 coatings

Study on HVOF Sprayed Nickel Coated MoS2 Coatings

Bailin Zha1,a, Xiaojing Yuan1,b, Li Jiang1,c and Zhihong Zha1,d

1Xian Research Institute of Hi-Tech, Xi’an Shaanxi, PR. China

a zhabailin@https://www.doczj.com/doc/c214265770.html,,

b yxj2003@https://www.doczj.com/doc/c214265770.html,,

c li501jiang@https://www.doczj.com/doc/c214265770.html,,

d zhihongzha@https://www.doczj.com/doc/c214265770.html, Keywords: Coating, Self-Lubricating, Tribological.

Abstract.The self-lubricating coating which is dense in microstructure with low porosity and degradation is sprayed by HVOF and the spray powder is Nickel coated MoS2 with 22%wt of MoS2. The mean bonding strength and hardness of Ni-MoS2 coating is respectively about 13.68 MPa and HRB94.5. Tribological performance is evaluated by the test of dry friction coefficient, which fluctuates from 0.25 to 0.32, while the wear granule is symmetry with a uniform distribution in size, moreover, the experiment results indicate the main wear failure mode of coating is abrasive wear. Introduction

High Velocity Oxygen Fuel flame (HVOF) spray is an important method of thermal spray that was developed in 1980’s. High particle velocity and moderate flame temperature contribute to high bonding strength and low porosity. Generally, the flame velocity of HVOF exceeds 2000m/s and the flame temperature is less than 2800℃. Figure 1 shows an improved HVOF system which operates on the same principle with traditional HVOF, its flame velocity and temperature can be adjusted in a wide range. Air or nitrogen can be introduced into the combustion chamber without the degradation of combustion stability, so that more flexibility can be gained. Numerical simulation and experiment results show that the flame velocity and temperature of the improved HVOF can be adjusted respectively from 500m/s to 2100m/s and 800k to 2800k. The flame flexibility brings many advantages to spray parameters optimization,especially when spraying low melting point materials that are characterized in decomposition and phase transformation.

Fig.1 Principle of an altered HVOF system

The self-lubricating technique is used widely in a pair of friction components when liquid lubricating is limited. In some friction face, it is very hard to design a lubricating cycle or to reserve the liquid lubricant. Furthermore, improper environment temperature, chemical corrosion or vacuum environment is disadvantageous for liquid lubricating for the degradation of lubricant performance. Therefore, solid lubricating is used as a substitute for liquid lubricating in this case. Graphite, sulfide and fluoride are the most widely used solid lubricant [1, 2]. MoS2 is a kind of chemical and thermal stable material with a layered hexagonal crystal system, which is similar with Graphite. MoS2

performed well tribological property in high temperature, low temperature, high velocity and high load environments. The metal based solid lubricant composite material integrates advantages of both metal and lubricant, which has good tribological performance with high strength. Nickel can wet MoS2, so nickel is usually used as metal adhesive for MoS2. Flame spray and plasma spray are used to manufacture nickel coated MoS2 coatings, which exhibit good triblological property. In this paper, the improved HVOF was employed to spray nickel coated MoS2coating and the microstructure and tribological characteristics have been investigated.

The commercially available nickel coated MoS2 (commercial brand KF-21, made in china) is used as feedstock. The morphology of the powder, composed with 22% of nickel and 78% of MoS2, which is incompact and distributed uneven in size is shown as figure 2. Actually, it is very hard to deposit the nickel coated MoS2 powder with HVOF gun, and it is greatly different from the traditional deposition process of carbide. KF-21 powder can only deposit successfully in a very narrow parameter range, while the spray parameters are shown in table 1.

Fig.2 Morphology of nickel coated MoS2 powder

morphology and microstructure of the powders are characterized by JSM-840 SEM that is used to investigate the coatings on cross section as well, while the coating bonding strength is measured by an adhesion test according to the standard ASTM C633-79. The hardness of the coatings is determined on polished cross section, and the tribological property is investigated according to Chinese standard GB12444.1-90.

Experiment results and analysis

Microstructure of Ni-MoS2 coatings. Figure 3 shows the microstructure of KF-21 coatings. Shown as the figure, the coating is dense in microstructure and adheres well with the substrate. There are some pores among the particles boundary, but no much pores exist in the coating substrate bonding interface. Some of the pores are nearly spherical. It may be caused by the gas release during the particles solidification. Melting point of MoS2 is 1185℃, and MoS2decomposed when heated in flame. The decomposition resultant sulfur reacts with oxygen to form oxide. Solubility of SO2 gas decreases with the decline of particle temperature, then, SO2 release to atmosphere from the coating during solidification, as a result, pores produced. Other pores formed for a local invalid bonding among particles. Within the coating, the black part is MoS2, and the gray part is nickel. Nickel and MoS2 distribute alternately, which shows particles deformed fully for high velocity after impacting on the substrate. The interlaced microstructure is advantageous to coating properties.

a) b)

Fig.3 Morphology of nickel coated MoS2 coating

a-bonding interface between the coating and substrate, b-inner part of the coating Bonding strength of coatings. Bonding strength is an important coating property, which includes bonding strength between coating and substrate and adhesion strength of the coating. Shown as table 2, average bonding strength of the Ni-MoS2 coating exceeds 13MPa, furthermore, all the samples fractured between the interface of substrate and coating, which indicates adhesion strength of coatings is stronger than bonding strength. The tested coating is 0.5mm in thickness, with the testing load of 0.5mm per min.

Figure 4 shows morphology of the fracture area. There are many tough sockets (the upper side of figure 4), around which nickel deformed like a flower, indicating nickel deformed acutely. Also, there are small black planes on the fracture area (the lower side of figure 4), which seems to be MoS2. Planes within the bonding interface contribute less to bonding strength, when loaded tensile stress, Ni-MoS2 coating fracture from the weak bonding area and part from the substrate finally. Hardness. Hardness of the Ni-MoS2 coating was tested. Samples are grinded and polished before testing. The results are shown in table 3. The average hardness of the coatings is HRB94.5, obviously, it is low. Figure 5 illustrates the morphology of the tested area, when the testing ball pressed the coating, a compressed spherical surface produced accordingly. As the figure shows, two pores exist on the surface with the original shape remained, no micro-crack left on the surface. On the boundary of the socket, the coating experienced extrusion and deformation, which caused accumulation of the coating with some micro-cracks distribute radially around the socket. MoS2 can slip easily for the layered hexagonal crystal system, and nickel has the ability to deform, therefore, Ni-MoS2 coating is capable to prevent the occurence and extension of micro-crack.

Fig.4 Fracture face Ni-MoS2 coating Fig.5 Morphology of hardness tested area

Dry friction experiment. Dry friction is a pair of friction components, rubbing each other without lubricant. According to standard GB12444.1-90, there are two components in the test, one is a circular shape sample, the other one is a rectangle shape sample with coating. The test system operates in a given force and round speed. The friction coefficient can be obtained while the two samples rubbing. The friction coefficient of Ni-MoS2 coating fluctuates from 0.25 to 0.32 when tested with 5kg friction load and 200r/min friction speed. Figure 6 shows the coating morphology after 12000 round experiments. The abrasion is even without cavity on the friction face, and the coating remains an interlaced distribution of Ni and MoS2.

T here are many small particles embedded in the coating after rubbing off. Figure 7 illustrates the particles rubbed off from the coating. Shown as the figure, the particles changed into cylinder shape. For the Ni-MoS2 coating is very easy to deform, small pieces of coating deformed into cylinder with friction force. These small cylinders act as rollers in a roller bearing, and they decrease the friction coefficient of the coatings. Obviously, the wear mechanism of the coatings is abrasive wear.

Fig.6 Morphology of the friction face Fig.7 Particles rubbed off from coating

Conclusions

Nickel coated MoS2 feedstock was sprayed by HVOF to deposit self lubricating coatings, mechanical and lubricating properties were investigated.

1. The Ni-MoS2 coating sprayed by the improved HVOF bonds well with the substrate. Nickel and MoS2 distribute alternately with dense microstructure, and the coating is easy to deform and slide, while the average bonding strength and hardness is 13.68 MPa and HRB 94.5 respectively.

2. The dry friction coefficient of Ni-MoS2 coating is from 0.25 to 0.32. Many small particles of the coating embedded in the friction face, which form the lubricating film. Small pieces of coating deformed into cylinder under friction force, which act as rollers in a roller bearing, and they decrease the friction coefficient of the coatings. Therefore, the wear mechanism of the coatings is abrasive wear.

References

[1] U.Mannlkko, A.Maatta, P.Vuoristo and T. MantylaS. Preparation and Characterization of

Powders and Coatings Containing Solid Lubricants. Proceedings of the 2003 International Thermal Spray Conference, Vol. 1, B.R. Marple and C. Moreau, Ed., May 5-8, 2003 (Orlando, FL), ASM International, 2003, p.243-248.

[2] G. Aggarwal, P. Walia, A. E. Segall, I. Smid and T.Eden. Development of Self-Lubricating

Coatings for Ti-6Al-4V Dovetails Using a High-Velocity Particle-Consolidation (HVPC) Process.

Proceedings of the 2006 International Thermal Spray Conference, May 15-18, 2006 (Seattle, Washington, USA), ASM International, 2006.

C语言程序设计第四版第六章答案_谭浩强

1、用筛选法求100之内的素数。解: #include #include int main() {int i,j,n,a[101]; for (i=1;i<=100;i++) a[i]=i; a[1]=0; for (i=2;i int main() {int i,j,min,temp,a[11]; printf("enter data:\n"); for (i=1;i<=10;i++)

{printf("a[%d]=",i); scanf("%d",&a[i]); } printf("\n"); printf("The orginal numbers:\n"); for (i=1;i<=10;i++) printf("%5d",a[i]); printf("\n"); for (i=1;i<=9;i++) {min=i; for (j=i+1;j<=10;j++) if (a[min]>a[j]) min=j; temp=a[i]; a[i]=a[min]; a[min]=temp; } printf("\nThe sorted numbers:\n"); for (i=1;i<=10;i++) printf("%5d",a[i]); printf("\n"); return 0; } 3、求一个3×3的整型矩阵对角线元素之和。解: #include int main() { int a[3][3],sum=0; int i,j; printf("enter data:\n"); for (i=0;i<3;i++) for (j=0;j<3;j++) scanf("%3d",&a[i][j]); for (i=0;i<3;i++) sum=sum+a[i][i]; printf("sum=%6d\n",sum);

C语言程序设计习题参考答案第四章(数组)

第四章数组参考答案 一、选择题:1、 B 2、C 3、D 4、C 5、C 6、B 7、D 8、B 9、B 10、A 二、填空题: 1、首地址 2、按行存放 3、一个字符 4、′\0′ 5、字符数组名或字符串 6、9 0 7、6 8、j-1 str[j-1] 9、62 10、s1[i]=s2[i]; 三、改错题 1、错误语句:int a[3][ ]={2,4,6,8,10,12,14,16,18}; 正确语句:int a[ ][3]={2,4,6,8,10,12,14,16,18}; 2、错误语句:if (str[2]>string) string=str[2]; 正确语句:if (strcmp(str[2],string)>0) strcpy(string,str[2]); 3、错误语句:char c[5]={'C','h ','i','n','a '}; 正确语句:char c[6]={'C','h ','i','n','a '};或char c[ ]={“China”}; 4、错误语句:int a[3]={3*0} ; 正确语句:int a[4]; 5、错误语句:scanf(“%d%d%d”,&a); 正确语句:for (i=0; i<3; i++) scanf(“%d”,&a[i]); 或scanf(“%d%d%d”, &a[0], &a[1], &a[2]); 四、编程题 1、用数组来处理,求解Fibonacci数列前40项:1,1,2,3,5,8,13,21…。 #include void main() { int i; int t[40]={1,1}; for(i=2;i<40;i++) t[i]=t[i-2]+t[i-1]; for(i=0;i<40;i++) { if(i%5==0) printf("\n"); printf("%15d",t[i]); } } 2、用选择法对20个整数排序(由大到小)。 #include void main() {int i,j,min,t,x[20]; for(i=0;i<20;i++) scanf("%d",&x[i]); for(i=0;i<19;i++) {min=i; for(j=i+1;j<20;j++) if(x[min]>x[j])min=j; t=x[i];

C程序设计(第四版)_谭浩强_第五章_课后习题答案

循环结构程序设计 P115 5.1 用while计算1至100的合. #include int main() { int i=1,sum=0; while(i<=100) //对于需要运算的值,要么在运算前可以赋值,要么一开始要指定. { sum=sum+i; i++; } printf("The sum is %d .\n",sum); return 0; } #include int main() { int i=1,sum=0; do// do-while可以做的事,用while都可以做到. { //do-while先做一次执行,再判断条件,而while却是先做一个条件,再执行. sum=sum+i; i++; }while(i<=100); printf("The sum is %d .\n",sum); return 0; } P118 5.3 比较do-while与while的差别. #include

{ int i,sum=0; printf("Please input a number :"); scanf("%d",&i); //输入10以内,正常,11的话,则sum仍然是0. while(i<=10) { sum=sum+i; i++; } printf("The sum of 1-10 is %d .\n",sum); return 0; } #include int main() { int i,sum=0; printf("Please input a number :"); scanf("%d",&i); //输入10以内,结果一样.输入11的话,先做操作,所以sum=11. do { sum=sum+i; i++; }while(i<=10); //此重点在于理解二者的差别. printf("The sum of 1-10 is %d .\n",sum); return 0; } #include int main() { int i,b=0,a,c; for(i=0;i<=1000;i++) { printf("Please input amount :"); //循环体内套有输出语句以及跳出语句. scanf("%d",&a); b=b+a; if(b>=100)

第5章-C语言程序设计(第2版)教材习题答案

【教材】《C语言程序设计(第2版)》清华大学出版社,黄保和,江弋编著。2011年10月第二版。ISBN:978-7-302-26972-4。售价:35元。 【答案版本】本习题答案为2012年2月修订版本。 一、选择题 1. 设有程序段”int k=10; while(k=0) k=k-1;”,则下面叙述正确的是D)循环体语句一次也不执行。 A. while循环执行10次 B. 循环是无限循环 C. 循环体语句执行一次 D. 循环体语句一次也不执行 2. 设有程序段”int x=0,s=0;while(!x!=0) s+=++x; printf(“%d”,s);”则A)运行程序段后输出1。 A. 运行程序段后输出1 B. 程序段执行无限次 C. 运行程序段后输出0 D. 程序段中的控制表达式是非法的 3. 下面循环语句中,错误的是D) int a=1,b=2;do b-- while(b= =0);。 A. int a=1,b=2; while(b--); B. int a=1,b=2; do a++; while(a==b); C. int a=1,b=2; while(a=3); D. int a=1,b=2; do b-- while(b==0); 4. 已知”int i=5;”,下列do…while循环语句的循环次数为C) 5。 do{ printf(“%d\n”,i--); } while(i!=0); A. 0 B. 1 C. 5 D. 无限 5. 循环语句”for(int i=0,j=10; i==j; i++,j--)”的循环次数是A) 0。 A. 0 B. 5 C. 10 D. 无限 6. 下述有关break语句的描述中,不正确的是C) break语句用于if语句的内嵌语句内,它结束该if语句。 A. break语句用于循环体内,它将结束该循环 B. break语句用于开关语句,它结束该开关语句 C. break语句用于if语句的内嵌语句内,它结束该if语句 D. break语句在一个循环体内可使用多次 7. 下面关于循环语句的描述中,错误的是B)循环体内必须同时出现break语句和continue 语句。 A. 循环体内可以包含有循环语句 B. 循环体内必须同时出现break语句和continue语句 C. 循环体内可以出现选择语句 D. 循环体可以是空语句 8. 以下不是死循环的是D)for(;(c=getchar()!=’\n’);)printf(“%c”,c);。 A. for(; ; x+=i); B. while(1) { x++; } C. for( i=10; ; i--) sum+=i; D. for( ; (c=getchar() )!=’\n’ ; ) printf( “%c”,c); 9. 执行语句”for(i=0;i++<3;);”后,变量i的值为C) 4。 A.2 B. 3 C. 4 D. 5 10.语句”for(x=0,y=0;y!=1&&x<4;x++);”是C)循环4次。 A. 无限循环 B. 循环次数不定 C. 循环4次 D. 循环3次

C语言程序设计(谭浩强)第四版-课后答案

第一章程序设计和C语言【第15页】 1-5 #include int main ( ) { printf ("**************************\n\n"); printf(" Very Good!\n\n"); printf ("**************************\n"); return 0; } 1-6 #include int main() {int a,b,c,max; printf("please input a,b,c:\n"); scanf("%d,%d,%d",&a,&b,&c); max=a; if (max #include int main() {float p,r,n; r=0.1; n=10; p=pow(1+r,n); printf("p=%f\n",p); return 0; }

3-2-1 #include #include int main() {float r5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5; p=1000; r5=0.0585; r3=0.054; r2=0.0468; r1=0.0414; r0=0.0072; p1=p*((1+r5)*5); // 一次存5年期 p2=p*(1+2*r2)*(1+3*r3); // 先存2年期,到期后将本息再存3年期 p3=p*(1+3*r3)*(1+2*r2); // 先存3年期,到期后将本息再存2年期 p4=p*pow(1+r1,5); // 存1年期,到期后将本息存再存1年期,连续存5次 p5=p*pow(1+r0/4,4*5); // 存活期存款。活期利息每一季度结算一次 printf("p1=%f\n",p1); // 输出按第1方案得到的本息和 printf("p2=%f\n",p2); // 输出按第2方案得到的本息和 printf("p3=%f\n",p3); // 输出按第3方案得到的本息和 printf("p4=%f\n",p4); // 输出按第4方案得到的本息和 printf("p5=%f\n",p5); // 输出按第5方案得到的本息和 return 0; } 3-2-2 #include #include int main() {double r5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5; p=1000; r5=0.0585; r3=0.054; r2=0.0468; r1=0.0414; r0=0.0072; p1=p*((1+r5)*5); // 一次存5年期 p2=p*(1+2*r2)*(1+3*r3); // 先存2年期,到期后将本息再存3年期 p3=p*(1+3*r3)*(1+2*r2); // 先存3年期,到期后将本息再存2年期 p4=p*pow(1+r1,5); // 存1年期,到期后将本息存再存1年期,连续存5次

C语言程序设计教程 清华大学出版社 陈明主编 第4章答案

第4章习题解答 一、选择题 1.在C语言中,函数返回值的类型最终取决于 A)函数定义时的函数首部所说明的函数类型B)return语句中表达式值的类型C)调用函数时主调函数所传递的实参类型D)函数定义时形参的类型 解析:函数返回值类型最终取决于定义函数时所定义的函数类型。 答案:A 2.设函数Fun()的定义形式为: void Fun(char ch, float x){} 则以下对函数Fun()的调用语句中,正确的是。 A)Fun("abc", 3.0); B)t = Fun('D', 16.5); C)Fun('65', 2.8); D)Fun(32, 32); 解析:选项A中"abc"是字符串,与形参不匹配:由于Fun函数的返回值类型为void,所以选项B中进行了赋值操作是不正确的;在选项C中,'65'是不合法的字符形式,单引号中应该是单个字符。只有选项D才是合法的函数调用形式。 答案:D 3.有以下程序: /* 文件路径名:ex4_1_3\main.c */ #include /* 标准输入/输出头文件*/ int f1(int x, int y) { return x > y ? x : y; } int f2(int x, int y) { return x > y ? y : x; } int main(void) /* 主函数main() */ { int a = 4, b = 3, c = 5, d = 2, e, f, g; /* 定义变量*/ e = f2(f1(a, b), f1(c, d)); f = f1(f2(a, b), f2(c, d));/* 调用函数*/ g = a + b + c + d - e - f; /* 算术运算*/ printf("%d,%d,%d\n", e, f, g); /* 输出e,f,g */ return 0; /* 返回值0, 返回操作系统*/ } 程序运行后的输出结果是。 A)4,3,7 B)3,4,7 C)5,2,7 D)2,5,7 解析:函数f1用于求两个数中的最大数,而函数f2用于求两个数中的最小数。因此有:e=f2(f1(a,b),f1(c,d))=f2(f1(4,3),f1(5,2))= f2(4,5)=4; f=f1(f2(a,b),f2(c,d)) =f1(f2(4,3),f2(5,2)) =f1(3,2)=3; g=a+b+c+d-e-f=4+3+5+2-4-3=7。

(完整版)C语言程序设计教程第五章练习题题目

单选题 1、关于数组的定义与初始化,下列哪一项是错误的() A.int arr[5] = {1,2,3,4,5}; B.int arr[] = {1,2,3,4,5}; C.int arr[5] = {1,2,3}; D.int arr[5] = {1,2,3,4,5,6}; 2、在定义数组int arr[10]后,下列选项中对arr的引用正确的是() A.arr[10] B.arr[6.3] C.arr(6) D.arr[0] 3、在C语言中,引用数组元素时,其数组下标的数据类型允许是() A.整型常量 B.整型表达式 C.整型常量或整型表达式 D.任何类型的表达式 4、若int arr[5] = {1,2,3}; 则arr[2]的值为() A.1 B.2 C.3 D.null 5、在执行int arr[][3] = {1,2,3,4,5,6}:语句后,arr[1][0]的值为() A.4 B.1 C.2 D.5 6、关于二维数组,下列选项能正确定义并赋初值的是() A.int n = 5,b[n][n]; B.int a[1][2] = {{1},{3}}; C.int c[2][] = {{1,2},{3,4}}; D.int a[3][2] = {{1,2},{3,4}}; 7、阅读下列程序段: char s[18] = "a book!"; printf("%.4s\n", s); 其输出结果为() A.a book! B.a book C.a bo D.a 8、阅读下列程序: int a[4][4] = { { 1, 3, 5, }, { 2, 4, 6 }, { 3, 5, 7 } }; printf("%d%d%d%d\n", a[0][0], a[1][1], a[2][2], a[3][3]);

C语言程序设计课后答案罗朝盛

第1章习题参考答案 1. (略) 2 3填空题 (1)main (2)函数的首部、函数体 (3){、} (4)main、main (5)语句、分号(;) 4 5选择题 (1) #include <> main() { int a, b, s; float t; printf("Enter A,B=?\n"); scanf("%d%d", &a, &b); s=a+b; t=a*b; printf("s=%d, t=%f\n", s, t); } (2) #include <> main() { printf("=================\n"); printf(" Hello! \n"); printf(" How do you do \n"); printf("=================\n"); } (3) #include <> main() {

int r, h; float v; printf("Enter R, H=?\n"); scanf("%d%d", &r, &h); v=*r*r*h; printf("v=%f\n",v); } 第2章 习题参考答案 一.(略) 二.填空题 (1) ab e d c b b a 2+ + + (2) (3) 16 (4) 10 (5) 16、16、11 (6) 4、10、6 (7) 18、3、3 (8) sin(65*180)+2*( +exp(y))/(x-y) (9) 25、25 (10) 27 (11) 4 (12) 0 四、编程题 1. #include <> main() { int x, a, b, c; printf("Enter a intger number x=?\n"); scanf("%d",&x); a=x /100; b=x%100/10; c=x%10;

《C语言程序设计》课后习题答案(第四版)谭浩强

第1章程序设计和C语言1 1.1什么是计算机程序1 1.2什么是计算机语言1 1.3C语言的发展及其特点3 1.4最简单的C语言程序5 1.4.1最简单的C语言程序举例6 1.4.2C语言程序的结构10 1.5运行C程序的步骤与方法12 1.6程序设计的任务14 1-5 #include int main ( ) { printf ("**************************\n\n"); printf(" Very Good!\n\n"); printf ("**************************\n"); return 0; } 1-6#include int main() {int a,b,c,max; printf("please input a,b,c:\n"); scanf("%d,%d,%d",&a,&b,&c); max=a; if (max

2.5结构化程序设计方法34 习题36 第章最简单的C程序设计——顺序程序设计37 3.1顺序程序设计举例37 3.2数据的表现形式及其运算39 3.2.1常量和变量39 3.2.2数据类型42 3.2.3整型数据44 3.2.4字符型数据47 3.2.5浮点型数据49 3.2.6怎样确定常量的类型51 3.2.7运算符和表达式52 3.3C语句57 3.3.1C语句的作用和分类57 3.3.2最基本的语句——赋值语句59 3.4数据的输入输出65 3.4.1输入输出举例65 3.4.2有关数据输入输出的概念67 3.4.3用printf函数输出数据68 3.4.4用scanf函数输入数据75 3.4.5字符数据的输入输出78 习题82 3-1 #include #include int main() {float p,r,n; r=0.1; n=10; p=pow(1+r,n); printf("p=%f\n",p); return 0; } 3-2-1 #include #include int main() {float r5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5; p=1000;

C语言程序设计第四版第七章答案-谭浩强

第七章函数 7.1写两个函数,分别求两个整数的最大公约数和最小公倍数,用主函数调用这两个函数,并输出结果两个整数由键盘输入。 maxyueshu(m,n) int m,n; { int i=1,t; for(;i<=m&&i<=n;i++) {if(m%i==0&&n%i==0) t=i; } return(t); } minbeishu(m,n) int m,n; {int j; if(m>=n) j=m; else j=n; for(;!(j%m==0&&j%n==0);j++); return j; } main() {int a,b,max,min; printf("enter two number is: "); scanf("%d,%d",&a,&b); max=maxyueshu(a,b); min=minbeishu(a,b); printf("max=%d,min=%d\n",max,min); } 7.2求方程的根,用三个函数分别求当b2-4ac大于0、等于0、和小于0时的根,并输出结果。从主函数输入a、b、c的值。 #include"math.h" float yishigen(m,n,k) float m,n,k; {float x1,x2; x1=(-n+sqrt(k))/(2*m); x2=(-n-sqrt(k))/(2*m); printf("two shigen is x1=%.3f and x2=%.3f\n",x1,x2); } float denggen(m,n) float m,n; {float x; x=-n/(2*m); printf("denggen is x=%.3f\n",x); }

C语言程序设计教程第四章练习试题解析[1]

单选题 1、关于C语言中的函数,下列描述正确的是() A.函数的定义可以嵌套,但函数的调用不可以嵌套 B.函数的定义不可以嵌套,但函数的调用可以嵌套 C.函数的定义和函数的嵌套均不可以嵌套 D.函数的定义和函数的调用均不可以嵌套 答案:B 解析:函数的定义不可以嵌套,但函数的调用可以嵌套 2、定义一个函数:exce((v1, v2), (v3,v4,v5),v6); 在该函数调用时,实参的个数为()个 A.3 B.4 C.5 D.6 答案:A 解析:(v1, v2), (v3,v4,v5)和v6一共三个实参 3、关于C语言中print()函数与scanf()函数,下列描述中正确的是() A.printf()函数可以向任何地方输出数据 B.printf()只向控制台输出数据 C.scanf()只能输入英文字母和数字 D.scanf()函数可以识别输入的空格 答案:B 解析:printf()是向控制台输出的函数 4、在C语言中,内部函数需要添加的关键字是() A.extern B.static C.this D.auto 答案:B 解析:在定义内部函数时,需要在函数的返回值类型前面添加static关键字(又称为静态函数)。 5、当调用时,会调用内部函数 A.当调用时,会调用内部函数 B.当调用时,会调用外部函数 C.当调用时,会调用两次,先调用内部函数再调用外部函数 D.都不调用,会报错 答案:A 解析:当内部函数与外部函数重名时,会优先调用内部函数 6、在C语言中,声明外部函数需要添加的关键字是() A.extern B.static C.this

答案:A 解析:声明外部函数的方式是在函数的返回值类型前面添加extern关键字 7、关于C语言中的局部变量,下列描述中错误的是() A.局部变量就是在函数内部声明的变量 B.局部变量只在函数内部有效 C.局部变量只有当它所在的函数被调用时才会被使用 D.局部变量一旦被调用,其生存周期持续到程序结束 答案:D 解析:当函数调用结束时局部变量就会失去作用 8、关于C语言中的全局变量,下列描述中正确的是() A.全局变量的作用域一定比局部变量的作用域范围大 B.静态类别变量的生存周期贯穿于整个程序的运行期间 C.函数的形参都属于全局变量 D.未在定义语句中赋初值的auto变量和static变量的初值都是随机值 答案:B 解析:选项1不对:如果程序中只有一个主函数,则在整个程序运行中,局部变量都在起作用; 选项3不对:除了C++的引用类型参数,所有函数的形参都是局部变量; 选项4不对:static变量定义时就存储地全局区,初始化为0; 9、当全局变量与局部变量重名时,那么在调用时() A.局部变量会被屏蔽 B.全局变量会被屏蔽 C.都不会调用,系统会报错 D.会调用两次,先调用局部变量,再调用全局变量 答案:B 解析:当局部变量与全局变量重名时,全局变量会被屏蔽。 10、在C语言中,关于变量的作用域,下列描述中错误的是() A.局部变量只在整个函数的运行周期中有效 B.全局变量的作用域为整个程序的运行周期 C.当全局变量与局部变量重名时,局部变量会屏蔽掉全局变量 D.全局变量会覆盖掉所有与它重名的局部变量 答案:D 解析:当全局变量与局部变量重名时,全局变量会被屏蔽掉 11、在C语言中,如果在一个函数的复合语句中定义了一个变量,则该变量() A.只在该复合语句中有效,在该复合语句外无效 B.在该函数中任何位置都有效 C.在本程序的原文件范围内均有效 D.此定义方法错误,其变量为非法变量 答案:D 解析:1、2与3错:函数复合语句中定义的变量在该复合语句中引用;但如果函数含有该变量,则在函数中可以引用该变量 4对:在C++中在复合语句中定义变量为合法,但在C语言中是非法的 12、C语言程序的基本单位是()。

C语言程序设计第14章在线测试

A B C D 、以下程序:5) printf( A B C D 、y均为则语句 printf( A B C D 、在函数中定义变量时,若省略存储类型符,系统默认存储类别为 A B C D 、下列选项中关于。 A r egister B 量 C r egister D register

B、p+=2,*++p C、p+=2,*p++ D、p+=2,++*p 2、以下叙述中,错误的叙述是: A、函数的形参都属于全局变量 B、全局变量的作用域不比局部变量的作用域范围大 C、静态(static)类别变量的生存期贯穿整个程序的运行期间 D、未在定义语句中赋初值的auto变量和static变量的初值都是随机值 3、下列选项中关于外部变量的作用域,正确的是( )。 A、外部变量的作用域是所在的源文件 B、外部变量的作用域是整个源程序 C、可以通过extern,将一些外部变量的作用域扩展到多个源文件 D、外部变量若定义为静态的,其他源文件不能使用该外部变量 4、下列选项中关于外部变量,正确的是( )。 A、main函数是主函数,不在main函数内部定义的变量都是外部变量 B、外部变量必须定义在源程序的开始处 C、外部变量必须定义在所有函数的外面 D、定义外部变量时,可以进行初始化 5、下列选项中关于变量的生存期,不正确的描述是( )。 A、auto型变量是静态存储的,其生存期等同于程序的运行期。 B、static变量是动态存储的,函数调用结束时,static变量所占用的内存单 元被释放 C、register变量都是动态存储的 D、外部变量都是静态存储的 第三题、判断题(每题1分,5道题共5分)

大学生C语言程序设计(第四版 谭洪强)实验5答案

实验四参考答案(参考答案) (1) 设计程序sy5-1.c,从键盘上输入一个3行3列矩阵各个元素的值,输出其主对角线元素和反向对角线元素之和。 算法分析: 对角线上的元素,1维和2维下标相同,反对角线元素,如果行下标为i,列下标就为2-i; 参考答案: #include int main() { int a[3][3]={{1,2,3},{4,5,6},{7,8,9}}; int i,j,sum=0; for(i=0;i<3;i++) sum=sum+a[i][i]+a[i][2-i]; //a[i][i]当前行的主对角线元素 //a[i][2-i]当前行的反对角线元素printf("矩阵的正、反对角线元素之和为:%d\n",sum); return 0; } 运行结果: (2) 设计程序sy5-2.c,找出一个3×4的矩阵中的最小值及其位置。 算法分析: 首先把二维数组中的第一个数即a[0][0]看成最小值,然后逐行逐列的去遍历每个元素,逐一判断每一个元素是否比最小值还好小,如果是,就改写最小值,并记录他的下标。 参考答案: #include #include int main() { int a[3][4]={{10,21,41,5},{12,15,46,35},{40,21,26,30}}; int i,j,row,colum,min; printf("数组a:\n"); for(i=0;i<3;i++) { for(j=0;j<4;j++) printf("%5d",a[i][j]);

printf("\n"); } min=a[0][0];row=0;colum=0; //首先把第一个数a[0][0]看成最小数 for(i=0;i<3;i++) //双重循环逐一遍历每个元素a[i][j] for(j=0;j<4;j++) if(min>a[i][j]) //如果当前值a[i][j]比最小值还要小 {min=a[i][j];row=i;colum=j;} //用a[i][j]改写最小值,并记下他们的下标printf("矩阵中最小元素是:%d,行下标是:%d,列下标是%d\n",min,row,colum); return 0; } 运行结果: (3) 设计程序sy5-3.c,定义一个3×3的二维数组,通过随机函数自动赋值。然后输入一个整数n,使数组左下三角(含对角线元素)元素中的值乘以n 。例如:若n的值为3,a 数组中的值为 | 1 9 7 |则程序运行后a数组中的值应为| 3 9 7 | | 2 3 8 | | 6 9 8 | | 4 5 6 | | 12 15 18 | 算法分析: 主要理解到对角线即以下元素包含哪些元素,即他们的下标变化。对每一行i来说,对角线以下的元素,他们的列下标是0,1,2,---,i;所以用外循环i遍历行,内循环j(从0到i),逐一遍历每一个a[i][j],并给a[i][j]赋值为他的n倍。最后输出矩阵。 参考答案: #include #include int main() { int a[3][3]; int i,j,n; printf("原来a的值:"); for(i=0;i<3;i++) //生成数组元素,并按矩阵形式输出 { for(j=0;j<3;j++) {a[i][j]=rand()%20; //rand()参看教材385页 //rand()%20 产生一个20以内的整数

c语言程序设计课后习题答案 第五章

/*练习5-3*/ #include int prime(int m) { int i; for(i=2;i<=m-1;i++) if(m%i==0) break; if(i==m) return 1; else return 2; } main() { int i,m,n,sum=0,a=0; printf("enter m and n:(1<=m<=n<=500)\n"); scanf("%d",&m); scanf("%d",&n); for(i=m;i<=n;i++) { if(prime(i)==1) sum=sum+i; a=a+1; } printf("之间的素数和为:%d\n",sum); printf("之间的素数个数为:%d\n",a); } /*习题5.1*/ #include int fn(int a,int n) { int i,sum=0,m=1,c; for(i=1;i<=n;i++) { sum=sum+m; m=m*10; } c=sum*a; return c; }

main() { int a,n,i,x,y=0; printf("enter a and n:\n"); scanf("%d",&a); scanf("%d",&n); for(i=1;i<=n;i++) { x=fn(a,i); y=y+x; } printf("y=%d\n",y); } /*习题5.2*/ #include int countdigit(int number,int digit) { int sum=0; while(number>0) { if(number%10==digit) sum=sum+1; number=number/10; } return sum; } main() { int number,y; printf("enter a number:\n"); scanf("%d",&number); y=countdigit(number,2); printf("y=%d\n",y); }

c语言程序设计第五版习题答案()

习题解析与答案 第1章C语言概述 一.简答题 1.概述C语言的主要特点。 【解答】 (1)语言简洁、紧凑,使用方便、灵活。 (2)数据类型丰富,表达能力强。 (3)运算符多样。C语言中的运算符包含的范围非常广泛。 (4)具有结构化的控制语句。如if…else语句、while语句、do while语句、switch语句、for语句。 (5)允许直接访问物理地址。C语言中含有的位和指针运算,能够直接对内存地址进行访问操作。 (6)所生成的目标代码质量高,可移植性好。 2.构成C语言程序的基本单位是什么它由哪几部分组成 【解答】函数是构成C语言程序的基本单位。一个完整的C程序一般由文件包含、宏定义、函数说明、变量和一个或若干个函数组成。 3.C语言程序的运行一般要经过哪几个步骤 【解答】(1)编辑;(2)编译;(3)连接,生成EXE文件;(4)执行。 二.运行程序写结果 1.输入下面程序并运行。 main() { int a1,a2,x; a1=100;

a2=50; x=a1-a2; printf(″x=%d\n″,x); } 【解答】运行结果为:x=50 2.输入下面程序并运行。 main() { int a1,a2,x; a1=10; a2=20; x=a1*a2; printf(″a1=%d,a2=%d\n″,a1,a2); printf(″x=%d\n″,x); } 【解答】运行结果为:a1=10,a2=20 x=200 3.输入下面程序并运行。 #include <> main() { printf("******\n"); printf(" *****\n"); printf(" ****\n"); printf(" ***\n"); printf(" **\n"); printf(" *\n"); } 【解答】运行结果为:****** ***** **** *** ** *

C语言程序设计第二版第四章第七章课后答案

1、输入函数scanf的参数错误,应该为:scanf("%f",&k); 2、|1234 1234 | 3、ff10 4、1,3,1 5、原字符串左边加空格再加字符串本省,字符个数总和为5个 6、scanf("%d,%d,%c,%c",&a1,&a2,&c1,&c2); 7、 printf("a+b=%d\n",a+b); printf("a-b=%d\n",a-b); printf("a*b=%d\n",a*b); printf("a/b=%d\n",a/b); printf("(float)a/b=%f\n",(float)a/b); printf("a%b=%d\n",a%b); 8、 void main() { float r; float s,c; printf("please input the number:"); scanf("%f",&r); if(r>=0) { s = 3.14*r*r; c = 2*3.14*r; printf("s = %f, c = %f\n",s,c); } else printf("you input number is error!"); } 9 void main() {int n; printf("please input the number:"); scanf("%d",&n); if(n>=100 && n <= 999) printf("%d%d%d",n%10,(n/10)%10,n/100); else printf("you input number is error!"); } 10、 void main() { int i,j,k; scanf("%d,%d,%d",&i,&j,&k); ((i%2 != 0?1:0) + (j%2 != 0?1:0)+(k%2 != 0?1:0)) == 2?printf("YES\n"):printf("NO\n"); } 11、 void main()

C语言程序设计1-4、12章习题解答

第1章C语言程序设计概述 1.1一个C程序的执行是从 A 。 A.从main()函数开始,直到main()函数结束 B.第一个函数开始,直到最后一个函数结束 C.第一个语句开始,直到最后一个语句结束 D.main()函数开始,直到最后一个函数结束 1.2在C程序中,main()的位置 C 。 A.必须作为第一个函数B.必须作为最后一个函数 C.可以任意D.必须放在它所调用的函数之后 1.3C语言源程序的基本单位是 B 。 A.过程 B.函数 C.子程序 D.标识符 1.4一个C源程序有且仅有一个一个函数和__零个或多个_____个其他函数。 1.5C语言源程序的语句分隔符是__分号___。 1.6C语言开发的四个步骤是_编辑源程序→对源程序进行编译→与库函数连接→运行 目标程序__ 。 1.7C语言有哪些主要特点? C主要特点有: 1.C语言简洁、紧凑,使用方便、灵活; 2.运算符丰富; 3.数据类型丰富; 4.C语言是结构化语言; 5.语法限制不太严格,程序设计自由度大; 6.可直接与机器硬件打交道,直接访问内存地址; 7.生成的目标代码质量高,程序执行效率高; 8.C语言适用范围广,可移植性好。 1.8简述C编译和运行的基本方法。 略。 1.9常用的集成开发工具有哪些?各有什么特点? 略。 1.10编写一个程序,在屏幕上输出以下内容: *************************** * You are welcome! * *************************** #include void main( ) /*主函数 */ { /*函数体开始*/ printf ("***************************\n"); /*输出语句*/ printf ("* You are welcome! *\n"); printf ("***************************\n"); } 1.11 编写一个C程序,输入a、b、c 3个值,输出其中最大者。

c语言程序设计第四版第四章答案谭浩强

第四章 什么是算术运算什么是关系运算什么是逻辑运算 解:略。 C语言中如何表示“真”和“假”系统如何判断一个量的“真”和“假” 解:设有一个逻辑表达式,若其结果为“真”,则以1表示;若其结果为“假”,则以0表示。但是判断一个逻辑量的值时,以0代表“真”,以非0代表“假”。例如3&&5的值为“真”,系统给出3&&5的值为1。 写出下面各逻辑表达式的值。设a=3,b=4,c=5。 (1) a+b>c&&b==c (2) a||b+c&&b-c (3) !(a>b)&&!c||1 (4) !(x=a)&&(y=b)&&0 (5) !(a+b)+c-1&&b+c/2 解: (1) 0 (2) 1 (3) 1 (4) 0 (5) 1 有3个整数a、b、c,由键盘输入,输出其中最大的数。 解: 方法一 #include <> main() { int a,b,c; printf("请输入3个整数:"); scanf("%d,%d,%d",&a,&b,&c); if(a main() { int a,b,c,temp,max; printf("请输入3个整数:"); scanf("%d,%d,%d",&a,&b,&c); temp=(a>b)a:b; /* 将a和b中的大者存人temp中 */ max=(temp>c)temp:c; /* 将a和b中的大者与c比较,取最大者*/ printf("3个整数的最大数是%d\n”,max); }

相关主题
文本预览
相关文档 最新文档