77范文网 - 专业文章范例文档资料分享平台

浙江省二级C语言上机考试题库(5)

来源:网络收集 时间:2019-08-03 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

y+=a[i]*t; t*=x; } p=fopen(\ fprintf(p,\ fclose(p); }

4. 设计程序:在正整数中找出1个最小的、被3、5、7、9除,余数分别为1、3、5、7的数,将该数以格式\写到考生目录中Paper子目录下的新建文件design.dat中。

#include #include void main() { FILE *p; int n=1; while(n%3!=1 || n%5!=3 || n%7!=5 || n%9!=7) n++; p=fopen(\ fprintf(p,\ fclose(p); }

5. 设计程序:在6至5000内找出所有的亲密数对,并将每对亲密数用fprintf(p,\语句写到考生目录中Paper子目录下的新建文件design.dat中。

说明:若a、b为1对亲密数,则a的因子和等于b、b的因子和等于a、且a不等于b。如:220、284是1对亲密数,284、220也是1对亲密数。

#include void main() { FILE *p; int a,b,c,k; p=fopen(\ for(a=6;a<=5000;a++){ c=1; for(k=2;k

6. 设计程序:将字符串s中的所有字符按ASCII值从小到大重新排序后,将排序后的字符串写入到考生目录中Paper子目录下的新建文件design.dat中。

#include

21

#include void main() { FILE *p; char *s=\ int i,j,k,n=strlen(s); p=fopen(\ for(i=0;is[j]) k=j; if(k!=i){ c=s[i]; s[i]=s[k]; s[k]=c; } } for(i=0;i

注意:在Turbo C下编译运行正确,在Visual C++6.0下编译运行有错,将指针s改为数组即可。 7. 设计程序:a、b、c为区间[1,100]的整数,统计使等式c/(a*a+b*b)=1成立的所有解的个数,并将统计数以格式\写入到考生目录中Paper子目录下的新建文件design.dat中,(若a=1、b=3、c=10是1个解,则a=3、b=1、c=10 也是解)。

#include void main() { FILE *p; int n=0,a,b,c; p=fopen(\ for(a=1;a<=100;a++) for(b=1;b<=100;b++) for(c=1;c<=100;c++) if(c/(a*a+b*b)==1) n++; fprintf(p,\ fclose(p); }

8. 设计程序:将满足条件pow(1.05,n)<1e6

#include #include void main() { float y=1.05; int n=1; FILE *p; p=fopen(\ while(pow(1.05,n)>=1e6 || pow(1.05,n+1)<=1e6) n++; fprintf(p,\ fclose(p); }

9. 设计程序:计算多项式a0+a1*sin(x)+a2*sin(x*x)+a3*sin(x*x*x)+??的值,并将其值以格式\写入到考生目录中Paper子目录下的新建文件design.dat中。

#include

22

#include void main() { FILE *p;

int i; float x=2.345,t=1.0,y=0.0;

float a[10]={1.2,-1.4,-4.0,1.1,2.1,-1.1,3.0,-5.3,6.5,-0.9}; p=fopen(\ y=a[0]; for(i=1;i<10;i++){ t*=x; y+=a[i]*sin(t); } fprintf(p,\ fclose(p); }

10. 设计程序:z=f(x,y)=(3.14*x-y)/(x+y),若x、y取值为区间[1,6]的整数,找出使z取最小值的x1、y1,并将x1、y1以格式\写入到考生目录中Paper子目录下的新建文件design.dat中。

#include void main() { FILE *p; float f(float x,float y),min; int x,y,x1,y1; p=fopen(\ x1=1; y1=1; min=f(x1,y1); for(x=1;x<=6;x++) for(y=1;y<=6;y++){ if(min>f(x,y)){ min=f(x,y); x1=x; y1=y; } } fprintf(p,\ fclose(p); }

float f(float u,float v) { return (3.14*u-v)/(u+v); }

11. 设计程序:在6至10000内找出所有的合数,并顺序将每个合数用语句“fprintf(p,\”写入到考生目录中Paper子目录下的新建文件design.dat中。

说明:某数等于其诸因子之和则该数为合数,如6=1+2+3,28=1+2+4+7+14则6、28就是合数。 #include void main() { FILE *p; int n,i,s; p=fopen(\ for(n=6;n<=10000;n++){

23

s=1; for(i=2;i

12. 设计程序:将数组a的每1行均除以该行上绝对值最大的元素,然后将a数组写入到考生目录中Paper子目录下的新建文件design.dat中。

#include #include void main() { float a[3][3]={{1.3,2.7,3.6},{2,3,4.7},{3,4,1.27}}; FILE *p; float x; int i,j; for(i=0;i<3;i++){ x=a[i][0]; for(j=1;j<3;j++) if(fabs(x)

13. 设计程序:数组元素x[i]、y[i]表示平面上某点坐标,统计所有各点间最短距离,并将其值以格式\写到考生目录中Paper子目录下的新建文件design.dat中。

#include #include

#define len(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) void main() { FILE *p; int i,j; float c,minc; float x[]={1.1,3.2,-2.5,5.67,3.42,-4.5,2.54,5.6,0.97,4.65}; float y[]={-6,4.3,4.5,3.67,2.42,2.54,5.6,-0.97,4.65,-3.33}; minc=len(x[0],y[0],x[1],y[1]); p=fopen(\ for(i=0;ic) minc=c; } fprintf(p,\ fclose(p);

24

}

14. 设计程序:计算表达式1+2!+3!+...+12!的值,并将计算结果以格式\写入到考生目录中Paper子目录下的新建文件design.dat中。

#include void main() { FILE *p; long s=1,k=1; int i; p=fopen(\ for(i=2;i<=12;i++){ k*=i; s+=k; } fprintf(p,\ fclose(p); }

15. 设计程序:寻找并输出11至999之间的数m,它满足m、m*m、m*m*m均为回文数。所谓回文数是指各位数字左右对称,例如121、676、94249等。满足上述条件的数如m=11,m^2=121,m^3=1331皆为回文数。请编制函数int JSValue(long m)实现此功能,如果是回文数,则函数返回1,反之则返回0。最后把结果输出到考生目录中Paper子目录下的新建文件design.dat中。

#include #include #include int JSValue(long m) { char s[15],n; int i; ltoa(m,s,10); n=strlen(s); for(i=0;i

void main() {

FILE *p;long m;

p=fopen(\ for(m=11;m<1000;m++) {

if(JSValue(m)&&JSValue(m*m)&&JSValue(m*m*m)) fprintf(p,\ }

fclose(p); }

16. 设计程序:x[i],y[i]分别表示平面上1个点的x、y坐标,求下列5点各点间距离总和,并将该数以格式\写到考生目录中Paper子目录下的新建文件design.dat中。

#include #include void main()

25

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库浙江省二级C语言上机考试题库(5)在线全文阅读。

浙江省二级C语言上机考试题库(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/676407.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: