欢迎来到天天文库
浏览记录
ID:41596472
大小:684.68 KB
页数:35页
时间:2019-08-28
《二级C语言上机题及答案(程序设计)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、程序设计题一、程序设计共113题第1题题号:319------------------------------------------功能:判断m是否为素数。------------------------------------------#include"stdio.h"voidwwjt();intfun(intm){/**********Program**********//**********End**********/}main(){intm,k=0;for(m=100;m<200;m++)if(fun(m)){p
2、rintf("%4d",m);k++;if(k%5==0)printf("");}printf("k=%d",k);wwjt();}voidwwjt(){FILE*IN,*OUT;intiIN,iOUT,i;IN=fopen("in.dat","r");if(IN==NULL){printf("PleaseVerifyTheCurrerntDir..ItMayBeChanged");}OUT=fopen("out.dat","w");if(OUT==NULL){printf("PleaseVerifyTheCurre
3、ntDir..ItMayBeChanged");}for(i=0;i<10;i++){fscanf(IN,"%d",&iIN);iOUT=fun(iIN);fprintf(OUT,"%d",iOUT);}fclose(IN);fclose(OUT);}答案:----------------------inti,k=1;if(m<=1)k=0;for(i=2;i4、--------------------功能:请编一个函数voidfun(inttt[M][N],intpp[N]),tt指向一个M行N列的二维数组,求出二维数组每列中最大元素,并依次放入pp所指一维数组中。二维数组中的数已在主函数中赋予。------------------------------------------#include#include#defineM3#defineN4voidwwjt();voidfun(inttt[M][N],intpp[N]){/*********5、*Program**********//**********End**********/}main(){intt[M][N]={{22,45,56,30},{19,33,45,38},{20,22,66,40}};intp[N],i,j,k;printf("Theoriginaldatais:");for(i=0;i6、k7、f,"");}fclose(rf);fclose(wf);}答案:----------------------inti,j;for(j=0;jpp[j])pp[j]=tt[i][j];}----------------------第3题题号:375------------------------------------------功能:从键盘上输入任意实数,求出其所对应的函数值。z=e的x次幂(x>10)z=log(x+8、3)(x>-3)z=sin(x)/((cos(x)+4)------------------------------------------#include#includevoidwwjt();doubley(floatx){/**********Prog
4、--------------------功能:请编一个函数voidfun(inttt[M][N],intpp[N]),tt指向一个M行N列的二维数组,求出二维数组每列中最大元素,并依次放入pp所指一维数组中。二维数组中的数已在主函数中赋予。------------------------------------------#include#include#defineM3#defineN4voidwwjt();voidfun(inttt[M][N],intpp[N]){/*********
5、*Program**********//**********End**********/}main(){intt[M][N]={{22,45,56,30},{19,33,45,38},{20,22,66,40}};intp[N],i,j,k;printf("Theoriginaldatais:");for(i=0;i6、k7、f,"");}fclose(rf);fclose(wf);}答案:----------------------inti,j;for(j=0;jpp[j])pp[j]=tt[i][j];}----------------------第3题题号:375------------------------------------------功能:从键盘上输入任意实数,求出其所对应的函数值。z=e的x次幂(x>10)z=log(x+8、3)(x>-3)z=sin(x)/((cos(x)+4)------------------------------------------#include#includevoidwwjt();doubley(floatx){/**********Prog
6、k7、f,"");}fclose(rf);fclose(wf);}答案:----------------------inti,j;for(j=0;jpp[j])pp[j]=tt[i][j];}----------------------第3题题号:375------------------------------------------功能:从键盘上输入任意实数,求出其所对应的函数值。z=e的x次幂(x>10)z=log(x+8、3)(x>-3)z=sin(x)/((cos(x)+4)------------------------------------------#include#includevoidwwjt();doubley(floatx){/**********Prog
7、f,"");}fclose(rf);fclose(wf);}答案:----------------------inti,j;for(j=0;jpp[j])pp[j]=tt[i][j];}----------------------第3题题号:375------------------------------------------功能:从键盘上输入任意实数,求出其所对应的函数值。z=e的x次幂(x>10)z=log(x+
8、3)(x>-3)z=sin(x)/((cos(x)+4)------------------------------------------#include#includevoidwwjt();doubley(floatx){/**********Prog
此文档下载收益归作者所有