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

上传资料

关闭

关闭

关闭

封号提示

内容

首页 C语言编程题库

C语言编程题库.doc

C语言编程题库

吴既包
2019-02-20 0人阅读 举报 0 0 暂无简介

简介:本文档为《C语言编程题库doc》,可适用于考试题库领域

C语言机械班用for循环从加到。(江松)#include<stdioh>intmain(void){ints=,ifor(i=i<=i){s=si}printf("d",s)}求从到的所有能被整除的数的和。(江松)#include<stdioh>intmain(void){inti=,sum=while(i<=){if(i==){sum=i}i}printf("sum=d",sum)}编写程序,求……n,直到累加和大于等于为止,并输出n和超出的值。(江松)#include<stdioh>intmain(void){inti,sumi=sum=while(sum<){sum=i*ii}printf("n=dsum=d",i,sum)}用冒泡排序法对个整数按照由小到大的顺序进行排序。(江松)#include<stdioh>#defineNvoidmain(){inti,aN,t=,j=for(i=i<Ni)scanf("d",ai)for(i=i<Ni)for(j=j<Nij)if(aj>aj){t=ajaj=ajaj=t}for(i=i<Ni)printf("d",ai)}输入三个整数x,y,z,请把这三个数由小到大输出。(江松)#include<stdioh>intmain(void){intx,y,z,tscanf("ddd",x,y,z)if(x>y){t=xx=yy=t}if(x>z){t=zz=xx=t}if(y>z){t=yy=zz=t}printf("smalltobig:dddn",x,y,z)}编写程序,输入一个整数,打印出它是奇数还是偶数。(江松)#include<stdioh>intmain(void){intascanf("d",a)if(a==){printf("oushu")}else{printf("jishu")}}编写程序,从键盘输入一个三位数,求出该数个位、十位、百位上的数字之和并输出。(江松)#include<stdioh>intmain(void){intaprintf("请输入一个位数n")scanf("d",a)if(a<||a>){printf("个位、十位、百位上的和是dn",(aaa))}}编写程序,把分钟换算成用小时和分钟表示,然后输出。(江松)#include<stdioh>intmain(void){inta=,b=,c,dc=abd=abprintf("分钟=d小时d分钟",c,d)}编写程序,读入三个双精度数,求出它们的平均值并保留此平均值。(江松)#include<stdioh>intmain(void)doublea,b,c,dprintf("输入三个双精度数:f,f,f",a,b,c)scanf("lf,lf,lf",a,b,c)d=(abc)printf("lf",d)}机械班C语言试题求二维数组的主对角线之积。编译#include<stdioh>intmain(void){inta={{,,,},{,,,},{,,,},{,,,}}i,j,sum=for(i=i<i){,for(j=j<j){if(i==j){Sum=sum*aij}}}Printf(“d”,sum)}求不是的倍数的累加和。#include<stdioh>intmain(void){inta=,s=while(a<){if(a==){acontinue}as=sa}printf("s=d",s)}从键盘输入个数,并将最大的数输出。#include<stdioh>intmain(void){inta,b,cscanf("d,d,d",a,b,c)if(a>=b){if(a>=c)printf("d",a)elseprintf("d",c)}else{if(b>=c)printf("d",b)elseprintf("d",c)}}当a=时,a=a当a=时,a=a当a=时,a=a其他,a=a#include<stdioh>intmain(void){intascanf("d",a)switch(a){case:a=abreakcase:a=abreakcase:a=abreakdefault:a=abreak}printf("d",a)}至的累加和。#include<stdioh>intmain(void){inttotal,count,numtotal=count=num=while(count<){total=totalnumcount=countnum}printf("total=d",total)}已知整型数组a中有十个元素,按从小到大排列并输出#include<stdioh>#defineNvoidmain(){inti,aN,t=,j=for(i=i<Ni)scanf("d",ai)for(i=i<Ni)for(j=j<Nij)if(aj>aj){t=ajaj=ajaj=t}for(i=i<Ni)printf("d",ai)}使用if语句编写程序,若a除以余则输出,若a除以不余则加输出。解:#include<stdioh>intmain(void){intascanf("d",a)if((a)==){}else{a=a}printf("d",a)}使用for语句编写程序,小于的奇数累加和。#include<stdioh>intmain(void){inti,s=for(i=i<i=i){s=si}printf("dn",s)}任意输入两个数,求这两个数的乘积。#include<stdioh>intmain(void){floata,bscanf("f,f",a,b)printf("f",a*b)}由键盘输入一个小写字母,将其转换成大写字母,并输出。#include<stdioh>intmain(void){charchch=getchar()ch=chPutchar(ch)}C语言机械班a={…}的累加和,当a=时跳出,并打印结果。(用for语句)(盛喆)参考答案#include<stdioh>intmain(void){inta,sumfor(a=,sum=a<=a){if(a==)breaksum=a}printf("d",sum)}从到累加和,其中将的倍数去掉。(用continuedowhile语句)(产文哲)参考答案#include<stdioh>intmain(void){inta,suma=,sum=for(a<=a){if((a)==))continuesum=a}printf("d",sum)}求一个×矩阵主对角线元素之积()参考答案#include<stdioh>intmain(void){inta,i,j,k=for(i=i<i){for(j=j<j){if(i==j){k=k*aij}}}printf("d",k)}定义一个数组a,使得a=…a=参考答案#include<stdioh>intmain(void){inta,i,jfor(i=i<i){for(j=j<j){aij=*ijprintf(“d”,aij)}}}给定一个数组a={,,,,,,,,,},用程序代码实现“求所有数组的和”。答案:#include<stdioh>intmain(void){inti,s=,a={,,,,,,,,,}for(i=i<i){s=sai}printf(“s=dn”,s)}a={,…},用程序代码实现“的倍数直接打印,否则打印”参考答案:#include<stdioh>intmain(void){inta={,…}scanf(“a=d”,a)if(a==){printf(“d”,a)}else{a=a}printf(“a=d”,a)}a={,,…},当a=时跳出循环,小于打印。(汪磊)参考答案:#include<stdioh>intmain(void){intafor(a=a<=a){if(a==)breakprintf(“a=d”,a)}}用数组求解之内的素数(丁瑞海)(注:素数是指一个大于的自然数,除了和它自身外,不能被其他自然数整除的数)程序为:#include<stdioh>intmain(void){inti,j,afor(i=i<i){ai=ifor(j=j<=ij){if(j<i)if(aij==)breakif(aij==)printf("d",ai)}}printf("n")}定义一个数组有个元素,将到分别给a到a。(丁方平)#include<stdioh>intmain(void){inti,afor(i=i<i){ai=i}for(i=i<i)printf(“dd”,ai)}a={……}的累加和,其中的倍数不计入。(袁业建)#include<stdioh>intmain(void){inta,suma=sum=for(a<=a){if(a==)continuesum=suma}printf(“d”,sum)}C语言试题安全工程公鸡每只元,母鸡每只元,小鸡只一元,问一百元钱买只鸡有多少种买法#include<stdioh>intmain(void){inta,b,c,n=for(a=a<=a)for(b=b<=b)for(c=c<=c)if(*a*bc==)nPrintf(“一共有d种n”,n):}求到的和#include<stdioh>intmain(void){inti,sumi=sum=while(i<=){sum=sumi}printf(“sum=d”,sum)}求到的累加和,其中的倍数不计入,不包括用for语句编程。#include<stdioh>intmain(void){inta,suma=sum=for(a<=a){if(a==)continuesum=suma}printf(“d”,sum)}从键盘输入两个数,将较大的数输出。#include<stdio>intmian(void){inta,bscanf(“d,d”,a,b)if(a>=b)printf(“d”,a)elseprintf(“d”,b)}、计算并输出之间不能被整除的整数的和#include<stdioh>intmain(void){inti,sum=for(i=i<=i){if(i!=){sum=sumi}}printf("dn",sum)}编程!!!!~!#include<stdioh>Intmain(void){intn,t=,s=For(n=n<=n){t=t*ns=st}Printf(“dn”,s)}计算…的值并输出,假定用a,b,c作为循环变量,累乘变量和累加变量的标识符答案:#include<stdioh>intmain(void){intaintb=intc=for(a=a<=a){b=b*c=b}printf(“d”,c)}程序題求到的累加合(用while编写)答案#include<stdioh>intmain(void){inti,sumi=,sum=while(i<=){sum=sumii=}printf("sum=d",sum)}

用户评价(0)

关闭

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

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

提示

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

文档小程序码

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

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/33

C语言编程题库

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利