下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 [c语言指针编程练习题]C语言练习题精选

[c语言指针编程练习题]C语言练习题精选.doc

[c语言指针编程练习题]C语言练习题精选

冰与火的爱恋q
2017-09-19 0人阅读 举报 0 0 暂无简介

简介:本文档为《[c语言指针编程练习题]C语言练习题精选doc》,可适用于初中教育领域

c语言指针编程练习题C语言练习题精选篇一:C语言练习题精选从键盘上输入两个整数求出它们的和#include“stdioh”voidmain{intx,y,sscanfscanfs=xyprintf}已知三角形的底和高求出三角形的面积。#include“stdioh”voidmain{intx,yfloatsx=y=s=x*yprintf}从键盘上输入三角形的底和高求出三角形的面积。#include“stdioh”voidmain{intx,yfloatsscanfscanfs=x*yprintf}已知三角形的三边长求出三角形的面积。#include“stdioh”#include“mathh”voidmain{inta,b,cfloatp,sa=b=c=p=s=sqrt**)printf}已知二元一次方程的三个系数求方程的一个根。#include“stdioh”#include“mathh”voidmain{inta,b,cfloatroota=b=c=root=*a*c))printf}编程实现符号函数。当x,则sgn=,当x=,则sgn=#include“stdioh”voidmain{floatxintyscanfify=ify=ify=printf=d”,x,y)}或者:#include“stdioh”voidmain{floatxintyscanfify=elseify=elsey=printf=d”,x,y)}或者:#include“stdioh”voidmain{floatxintyscanfy=::printf=d”,x,y)}从键盘上输入数字星期在屏幕上显示英文星期。#include“stdioh”voidmain{floatxscanfswitch{case:printfbreakcase:printfbreakcase:printfbreakcase:printfbreakcase:printfbreakcase:printfbreakcase:printfbreakdefault:printf,}从键盘输入三角形的三边长判断出这三边能否构成三角形#include“stdioh”voidmain{inta,b,cscanfscanfscanfif>b)>a)printfelseprintf}从键盘输入三个整数将这三个数按从大到小的顺序排列起来#include“stdioh”voidmain{inta,b,c,tempscanfscanfscanfif)printfif)printfif)printfif)printfif)printfif)printf}或者这样写:#include“stdioh”voidmain{inta,b,c,tempscanfscanfscanfif{temp=aa=bb=temp}if{temp=aa=cc=temp}if{temp=bb=cc=temp}printf}从键盘输入二个整数求出最大值。#include“stdioh”voidmain{inta,b,tempscanfscanfiftemp=aelsetemp=bprintf}从键盘输入三个实数求出最大值。#include“stdioh”voidmain{floata,b,c,tempscanfscanfscanfiftemp=aelsetemp=biftemp=cprintf}从键盘输入三个整数在一个程序中既要求出最大值还要求出最小值。#include“stdioh”voidmain{inta,b,c,max,minscanfscanfscanfif{max=amin=b}else{max=bmin=a}ifmax=cifmin=cprintf}使用for循环编程求出到的和#include“stdioh”voidmain{inti,s=fors=siprintf}使用当循环编程求出到的和#include“stdioh”voidmain{inti=,s=while{s=sii}printf}使用当循环编程求出到的和#include“stdioh”voidmain{inti=,s=do{s=sii}whileprintf}从键盘输入个实数求出最大值#include“stdioh”voidmain{intifloatx,maxscanfmax=xfor{scanfifmax=x}printf}从键盘输入个整数求出最小值#include“stdioh”voidmain{intix,minscanfmin=xfor{scanfifmin=x}printf}从键盘输入个整数求出它们的平均值#include“stdioh”voidmain{intia,s=floataver=for{scanfs=si}aver=sprintf}编程在屏幕上输出具有行的正三角形,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#include“stdioh”voidmain{inti,jfor{forprintfforprintfprintf},求出的阶乘。#include“stdioh”voidmain{intilongp=forp=p*iprintf,从键盘输入个整数求出不大于所有数的和#include“stdioh”voidmain{inti,s=,xfor{scanfifs=sx}printf,从键盘输入一个整数判断这个数是否为素数#include“stdioh”voidmain{inti,x,flag=scanffor{if{flag=break}}ifprintfelseprintf,从键盘输入个整数求出它们的和#include“stdioh”voidmain{inti,s=,xfor{scanfs=sxi}printf,从键盘输入个整数求出它们的平均值及比平均值大的数#include“stdioh”voidmain{inti,s=,xfloataver=for{scanfs=sxi}aver=sprintffor{ifprintf},已知五个整数,,,求出最大值#include“stdioh”voidmain{inti,x={,,,},maxmax=xforifmax=xiprintf,从键盘输入个整数求出它们的最小值并求最小值所在位置#include“stdioh”voidmain{inti,min,x,pos=forscanfmin=xpos=forif{min=xipos=i}printf,已知五个整数,,,按从大到小的顺序排列起来#include“stdioh”voidmain{intj,k,t,b={,,,}forforif{t=bjbj=bkbk=t}forprintf}从键盘输入个实数按从大到小的顺序排列起来#include“stdioh”voidmain{inti,j,kfloatbtforscanfforforif{t=bjbj=bkbk=t}forprintf}某班有名学生某门考试结束后请按段统计出各分数段的人数#include“stdioh”voidmain{intj,xfragmentforscanfforfragmentxj=fragmentxjforprintf}或者写成:#include“stdioh”voidmain{intj,xt,fragmentforscanffor,t=xjfragmentt=fragmentt,forprintf}从键盘上输入两个字符串并将它们交换后输出#include“stdioh”#include“stringh”voidmain{intj,kcharch,ch,tscanfscanfstrcpystrcpystrcpyprintf}已知五个字符串”China”,”American”,”Japan”,”France”,”Australia”,编程将它们按从小到大的顺序排列起来#include“stdioh”#include“stringh”voidmain{intj,kchart,b=,”China”,”American”,”Japan”,”France”,”Australia”}forforif){strcpystrcpystrcpy}forprintf}篇二:浙江大学数值分析C语言编程习题C语言编程习题第二章习题用二分法编程求xx=的所有实根。)#include#include#defineNdoubleA,B,Cdoublef{return}voidBM{intkdoublex,xedoublevaluea=fdoublevalueb=fifreturnprintffor{x=xe=ifprintfprintf=gnn”,f)return}if*felsea=x}printf}intmain{doublea,b,eps,eps,step,startprintfscanfprintfscanffordoubleright=startstepBM}return}运行:PleaseinputA,B,C:Pleaseinputa,b,step,eps,eps:eeFindingrootintherange:,Thexvalueis:f=Findingrootintherange:,Thexvalueis:f=Findingrootintherange:,Thexvalueis:f=Findingrootintherange:,Thexvalueis:f=有时若把判别语句if改为if会提高精度对同一题运行结果:Findingrootintherange:,Thexvalueis:f=eFindingrootintherange:,Thexvalueis:f=eFindingrootintherange:,Thexvalueis:f=eFindingrootintherange:,Thexvalueis:f=e习题请用埃特金方法编程求出x=tgx在附近的根。#include#include#defineN#definePIvoidSM{intkdoublexdoublex,xfor{x=sincosx=sincosx=x*ifprintfreturn}x=x}printf}intmain{doubleeps,xprintfscanfSMreturn}运行:Pleaseinputeps,x:eThexvalueis:习题(请编出用牛顿法求复根的程序并求出P=zzzz=接近于z=i的零点。#include#include#defineMAXTIMEStypedefstruct{doublereal,image}COMPLEXCOMPLEXAa={{,},{,},{,},{,},{,}}COMPLEXBb={{,},{,},{,},{,}}COMPLEXzero={,}doubleeps=edoubleeps=eCOMPLEXmulti{COMPLEXresult=areal*brealaimage*bimageresultimage=aimage*brealareal*bimagereturnresult}COMPLEXDiv{COMPLEXzdoubless==brealzimage=bimagez=multi=zimage=zimagesreturnz}COMPLEXadd{COMPLEXresult=arealbrealresultimage=aimagebimagereturnresult}COMPLEXsubtract{COMPLEXresult=arealbrealresultimage=aimagebimagereturnresult}COMPLEXtimes{intiCOMPLEXresult={,}forresult=multireturnresult}doubledistance{returnsqrt**)}doublecomplexabs{returnsqrt}COMPLEXf{intiCOMPLEXresult=zerofor{result=add))}returnresult}COMPLEXff{intiCOMPLEXresult=zerofor{result=add))}returnresult}intmain{COMPLEXz,z,resultdoublex,yintkprintfscanf=xzimage=yfor{z=subtract,ff))result=fifprintf,f=n”,,zimage,,resultimage)return

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/30

[c语言指针编程练习题]C语言练习题精选

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利