关闭

关闭

关闭

封号提示

内容

首页 c语言题库(编程)河南工业大学 河工大 c语言期末考试题库(C languag…

c语言题库(编程)河南工业大学 河工大 c语言期末考试题库(C language exam (programming) Henan University of Technology river engineering C language exam final exam).doc

c语言题库(编程)河南工业大学 河工大 c语言…

上传者: tang中维 2017-10-11 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《c语言题库(编程)河南工业大学 河工大 c语言期末考试题库(C language exam (programming) Henan University of Technology river engineering C language exam final exam)doc》,可适用于人文社科领域,主题内容包含c语言题库(编程)河南工业大学河工大c语言期末考试题库(Clanguageexam(programming)HenanUniversityofTec符等。

c语言题库(编程)河南工业大学河工大c语言期末考试题库(Clanguageexam(programming)HenanUniversityofTechnologyriverengineeringClanguageexamfinalexam)c语言题库(编程)河南工业大学河工大c语言期末考试题库(Clanguageexam(programming)HenanUniversityofTechnologyriverengineeringClanguageexamfinalexam)Two,programmingthereisafunction:whenx<,y=whenx=,y=whenx>,y=Writeaprogram,enterthexvalue,theoutputvalueofY#include<stdioh>Void(main){Intx,yPrintf("pleaseinputx:")Scanf(d,x)If(x<)Y=Elseif(x=)Y=ElseY=Printf(y=d,y)}inputthreenumbers,bythesethreenumbersfrombigtosmallorder,andtheoutputofthenumberthree#include<stdioh>Void(main){inta,B,C,temp=Printf("pleaseinputa,B,c:)Scanf("ddd",a,b,c)If(a<b){temp=aa=bb=temp}If(a<c){temp=aa=cc=temp}If(b<c){temp=bb=cc=temp}Printf("fromlargetosmall:d,d,dn,a,B,C)}therearethreeintegersa,B,C,fromthekeyboardinput,theoutputofwhichthelargestVoid(main){Inta,B,C,maxPrintf("inputthreenumbers:n)Scanf(ddd,a,b,c)If(a>ba>c)Max=aIf(b>ab>c)Max=bIf(c>ac>b)Max=cPrintf(themaximumis:dn,Max)}programmingforroundarea,circumferenceFortheradiusofthecirclefromthekeyboardinput,theoutputrequesttext,taketwodecimalplaces#include<stdioh>#definePI(main){FloatR,l,sPrintf("pleaseentertheradius:n")Scanf(f,r)L=*pi*rS=pi*r*rPrintf(l=fns=fn,l,s)}isabitdifficulttopiecewisefunction:whenx<,y=|x|when=x=,y=xwhenx>,y=sqrt(x)Writeaprogram,enterthexvalue,theoutputvalueofYwriteaprogramtodeterminewhetheraparticularyearisaleapyear(aconditionthatisdivisibleby,butnotdivisibleby,orcanbedivisibleby)#include<stdioh>Int(main){Intyear,leapScanf(d,year)If(year==){If(year==){If(year==)Leap=ElseLeap=}ElseLeap=}ElseLeap=If(LEAP)Printf("dis",year)ElsePrintf("disnot",year)Printf("aleapyearn")Return}EnteradegreesFahrenheitandCelsiustemperatureoutput,theoutputrequirementsoftext,taketwodecimalplacesTheformulaisc=(f)#include<stdioh>Int(main){FloatF,cPrintf("entertheFahrenheittemperature:n")Scanf(f,f)C=(f)Printf("thecorrespondingCelsiustemperatureis:fn,C)}EightThereisafunction:whenx<,y=|x|when<=x<,y=xwhenx>=,y=xWriteaprogram,enterthexvalue,theoutputvalueofYinputthreenumbers,thethreenumbersinascendingorder,andtheoutputofthenumberthree#include<stdioh>Void(main){inta,B,C,temp=Printf("pleaseinputa,B,c:)Scanf("ddd",a,b,c)If(a>b){temp=aa=bb=temp}If(a>c){temp=aa=cc=temp}If(b>c){temp=bb=cc=temp}Printf("to:d,d,dn,a,B,C)}enteracharacter,determinewhetheritisalowercaseletter,ifitis,itwillbeconvertedtouppercaseifnot,noconversionThenfinallyoutputcharacter#include<stdioh>#include<stringh>Void(main){CharaScanf(c,a)If(islower(a))A=aPrintf(cn,a)}programmingforcylindricalvolume,cylindricalsurfaceareaFortheradiusofthecircle,thecolumnheightfromthekeyboardinput,theoutputrequesttext,taketwodecimalplaces#include<stdlibh>Intmain(intargc,char*argv){FloatR,h,l,s,SQ,VQ,vzFloatpi=Printf("pleaseenterthecircleofradiusr,cylinderH:")Scanf(f,f,r,h)L=*pi*rS=pi*r*rSq=*pi*r*rVq=*pi*r*rVz=pi*r*r*hPrintf("circumference:l=fn,l)Printf("circlearea:s=fn,s)Printf("roundtablearea:sq=fn,sq)Printf("ballsize:vq=fn,VQ)Printf("cylindricalvolume:vz=fn,VZ)System("PAUSE")Return}piecewisefunction:whenx<,y=xwhen=x=,y=x^whenx>,y=xWriteaprogram,enterthexvalue,theoutputvalueofYtherearethreeintegersa,B,C,fromthekeyboardinput,outputtheminimum#include<stdioh>Int(main){Inta,B,C,temp,minPrintf("pleaseinputthreeintegers:")Scanf(d,d,d,a,b,c)Temp=(a<b)a:bMin=(temp<c)temp:cPrintf("thenumberthreeinthedecimalisdn,min)Return}enteracharacter,determinewhetheritisacapitalletter,ifitis,itwillbeconvertedtolowercaselettersifnot,noconversionThenfinallyoutputcharacter#include<stdioh>Void(main){CharcPrintf("inputch:")(c=getchar)If(c>='A'c<='Z'){C=cPrintf(c,C)}Elseprintf(c,C)}Threesidesofinputtriangle,triangleareaForthetriangleareaformula面积=SQRT(S(SA)(SB)(SC))其中S=(abc)#包括<stdioh>#包括<<数学。”无效main(){浮BCS面积printf(“依次输入ABC:”)scanf(“fff”BC)S=(浮动)*(ABC)面积=(浮动)sqrt(*(SA)*(SB)*(SC))printf(“面积为:f”地区)}编程求~~~~~的值并输出结果。#包括<stdioh>国际main(){intn=总和=JM=我为(i=i<=i){M=为(J=J<=*我j)M=M*J金额=金额M}printf(“金额=dn”总和)返回}。猴子吃桃问题。猴子第一天摘下若干个桃子当即吃了一半还不过瘾又多吃了一个。第二天早上又将剩下的桃子吃掉一半又多吃一个。以后每天早上都吃了前一天剩下的一半零一个。天早上想吃时就剩一个桃子了求第一天共摘了多少个桃子到第。#包括<stdioh>无效main(){int天静态X=天=而(天>){X=(X)*天}printf(“桃子总数=dn”X)}。输出所有的”水仙花数”所谓”水仙花数”是指一个位数其各位数字立方和等于该数本身。#包括<stdioh>国际main(){intijknprintf(“水仙花数是”)对于(n=n,N){我=NJ=NI*k=n如果(n==我*我*我**JJJKKK)printf(“d”n)}printf(“n”)返回}。编程求~之间的所有素数并输出结果。#包括<stdioh>intmain(void){a我J为(i=i<i)一个我=I为(i=i<i)为(j=iJ,j)如果(一个我和一个J为我==)一个J=为(i=i<i)如果(一个我)printf(“d”一个我)返回}编程求~~~~~的值并输出结果。#包括<stdioh>国际main(){intn=总和=JM=我为(i=i<=i){M=为(J=J<=ij)M=M*J金额=金额M}printf(“金额=dn”总和)返回}。用π,,,„公式求PI的近似值的绝直到某一项对值小于的次方为止。#包括<stdioh>#包括<<数学。”国际main(){符号=双PI=n==项而(晶圆厂(术语)>=e){π=π名词n=n标志=符号术语符号N=}PI=πprintf(“PI=fn”PI)返回}。一个球从m高度自由落下每次落地后又反跳回原高度的一半再落下再反弹。求它在第次落地时共经过多少米,#包括“stdioh”#包括“stdioh”main(){浮法锡=HN=锡intn对于(n=n<=n){Sn=SnHN*第N次落地时共经过的米数*HN=HN*第N次反跳高度*}printf(“总道路为fnSn)getch()}。输入两个正整数M和N求其最大公约数和最小公倍数。#包括<stdioh>国际main(){intprnm温度printf(“请输入两个正整数NM:“)scanf(“dd”与N和M)如果(n,m){温度=Nn=mM=温度}P=NM而(M~=){R=nmn=mM=R}printf(“它们的最大公约数为:dn”n)printf(“它们的最小公约数为:dn”PN)返回}。利用循环编程求~~~„~的值并输出结果。main(){intIJN和=为(i=i<=i){n=为(J=J<=我j)n=J总和=n}printf(“d”总和)}。有一分数序列:,,求出这个数列前项之和。#包括<stdioh>main(){intixy一浮总和=x=Y=为(i=i<i){总和=(浮动)(x)Yprintf(“ddn”xy)A=Xx=xyY=A}printf(“fn”总和)}。求斐波那契数列前个数。这个数列有以下特点:第和第个数为从第个数开始该数是其前面两个数之和。#包括<stdioh>#定义N长Fibonacci(intn){如果(==N||==n)返回其他的返回斐波那契(n)斐波那契(n)}intmain(void){intiprintf(“斐波那契数列的前项n”)为(i=i<){printf(“ld”斐波那契(我))如果(我==)printf(“n”)}printf(“n”)返回}。一个数如果恰好等于它的因子之和这个数就称为完数。例如的因子为、、而=以内所有完数编程求因此是完数。#包括<stdioh>无效main(){intijint和为(i=i<i){总和=for(j=j<ij)if(ij==)sum=sumjif(sum==)printf("d是完数n",sum)}}求s=aaaaaaaaa(n个a)之值其中a是一个数字,n代表a的位数例如:(此时n为),n由键盘输入#includestdioh><intmain(){inta,n,=,sn=,tn=printf(a,n=:")scanf("dd"a,n)while(<=n){tn=tnasn=sntna=a*}printf("aaaaaa=dn",sn)return}编程求~之间的所有素数,并输出结果#includestdioh><#includemathh><intmain(){intn,k,i,m=for(n=n<=n=n){k=sqrt(n)for(i=<=ki)if(ni==)breakif(i>=k){printf("d",n)m=m}if(m==)printf("n")}printf("n")return}输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数#include"stdioh"main(){charcinti=,y=,k=,l=while((c=getchar())!='n'){if(c>=c<=||c>=c<=)elseif(c>=c<=)jelseif(c==)celsel}printf("=d,j=d,k=d,l=dn",i,j,k,l)}将一个数组中的值按逆序重新存放例如,原来顺序为,,,,,要求改为,,,,,#includestdioh><#definenintmain(){intanin,thetempprintf("enterarraya:n")for(i=i<ni)scanf("d"ai)printf("arraya:n")for(i=i<ni)printf("d",ai)for(i=i<ni){temp=aiai=anan=temp}printf("nnow,arraya:n")for(i=i<ni)printf("d",ai)printf("n")return}编写一个函数,求数列n,利用主函数调用这个函数并输出结果#includestdioh><main(){floatin=,sum=,nprintf("inputanumbern:")scanf("f",n)while(<=n){sum=ini=i}printf("fn",sum)}将一个二维数组inta的行和列的元素互换,存到另外一个二维数组中#includestdioh><intmain(){inta={{,,,},{,,,tetrahydro,,,,,},{,,,}}intb,i,jprintf("arrarya:n")for(i=i<=i){for(j=,j<=j){printf("d",aij)bji=aij}printf("n")}printf("arrayb:n")for(i=i<=i){for(j=,j<=j)printf("d",bij)printf("n")}return}利用循环输出以下图形***************#includestdioh><intmain(){inti,j,mfor(i=in<=i){m=for(m=m<im)printf("")for(j=,j<=ij)printf("*")printf("n")}return}用冒泡排序法对输入的个数进行降序排序,并存入数组中#includestdioh><intmain(){intainti,j,tprintf("inputnumbers:n")for(i=i<i)scanf("d"ai)printf("n")for(j=,j<j)for(i=i<ji)if(ai<(ai){t=aiai=aiai=t}printf("thesortednumbers:n")for(i=i<i)printf("d",ai)printf("n")return}有一个乘的矩阵,要求编程序求出其中值最大的那个元素的值,以及其所在的行号和列号#includestdioh><intmain(){inti,j,ro=,colum=,maxinta={{,,,},{,,,tetrahydro,,,,,},{,,,}}max=afor(i=i<=i)for(j=,j<=j)if(aij>max){max=aijrow=colum=j}printf("max=d,row=d,colum=dn",max,rowcolum)return}用冒泡排序法对输入的个数进行升序排序,并存入数组中#includestdioh><intmain(){intainti,j,tprintf("inputnumbers:n")for(i=i<i)scanf("d"ai)printf("n")for(j=,j<j)for(i=i<ji)if(ai>ai){t=aiai=aiai=t}printf("thesortednumbers:n")for(i=i<i)printf("d",ai)printf("n")return}利用循环,输出以下图形*************************#includestdioh><intmain(){chara={'*','*','*','*','*')inti,j,kcharspace=''for(i=i<i){printf("n")printf("")for(j=j<=ij)printf("c",space)for(k=k<k)printf("c",ak)}printf("n")return}输出以下杨辉三角形(要求输出行)#includestdioh><#definenintmain(){inti,j,annfor(i=i<ni){ainin=ai=}for(i=<ni)for(j=j<=j)aij=ajajfor(i=i<ni){(j=,j<=ij)printf("d",aij)printf("n")}printf("n")return}利用循环输出以下图形****************#includestdioh><intmain(){inti,j,mfor(i=in<=i){m=for(m=m<=m)printf("")for(j=,j<*j)printf("*")printf("n")}return}利用循环,输出以下图形****************#includestdioh><intmain(){intn,i,jscanf("d",n)for(i=i<ni){for(j=nij>i)printf("")for(j=,j<*i,j){intk=jif(k>)c=printf("c"'*'k)}printf("n")}return}求一个的整型矩阵对角线元素之和#includestdioh><main(){inta,i,j,sum=printf("请输入数组元素:(*)n")for(i=i<i)for(j=,j<j)scanf("d"aij)printf("n")printf("数组为:n")for(i=i<i){(j=,j<j)printf("d",aij)printf("n")}printf("n")printf("对角线的和:n")for(i=i<i)for(j=,j<j)if(i==j||in==j)sum=aijprintf("d"n"sum)}编写程序,将两个字符串连接起来,不要使用strcat函数intmain(){char*a="qwet"*b="woei"charcinti,jfor(i=,y=*(ai)i,j)cj=*(ai)for(i=*(b)i,j)cj=*(b)cj=''for(i=cii)printf("c"ci)}写一个函数,Forthelargertwointegers,withthemainfunctioncallsthefunction,andtheoutputresultsoftwointegersfromthekeyboardinput#include<stdioh>IntmaxNum(inta,intb){Return(a>bA:b)}Void(main){Inta,B,maxPrintf("Entertwonumbersn!")Scanf(dd,a,b)Max=maxNum(a,B)Printf(Max:dn,Max)}writethegreatestcommondivisoroftwofunctionsrespectivelyfortwointegersandLCM,thetwofunctioncallsinthemainfunction,andoutputresults,twointegersfromthekeyboardinput#include<stdioh>IntHCF(int,int)IntLCD(int,int,int)Void(main){Intu,V,h,lScanf(d,d,u,v)H=hcf(U,V)Printf(HCF=dn,H)L=lcd(U,V,H)Printf(LCD=d,l)}IntHCF(intu,intV){Intt,rIf(v>u){T=uU=vV=tWhile((r=uv)=!){U=vV=r}Return(V)}IntLCD(intu,intV,inth){Return(u*vh)}Theoutputpattern#include<stdioh>Int(main){intI,J,kFor(i=i<=i){for(j=j<=ij)("printf")For(k=k<=*ik)Printf("*")Printf("n")}For(i=i<=i){for(j=j<=ij)("printf")For(k=k<=*ik)Printf("*")Printf("n")}Return}

职业精品

用户评论

0/200
    暂无评论

精彩专题

上传我的资料

热门资料

资料评价:

/34
0下载券 下载 加入VIP, 送下载券

意见
反馈

返回
顶部