福建省高等学校计算机等级考试二级C语言 编程题.docx

上传人:b****5 文档编号:3199060 上传时间:2022-11-20 格式:DOCX 页数:4 大小:19.84KB
下载 相关 举报
福建省高等学校计算机等级考试二级C语言 编程题.docx_第1页
第1页 / 共4页
福建省高等学校计算机等级考试二级C语言 编程题.docx_第2页
第2页 / 共4页
福建省高等学校计算机等级考试二级C语言 编程题.docx_第3页
第3页 / 共4页
福建省高等学校计算机等级考试二级C语言 编程题.docx_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

福建省高等学校计算机等级考试二级C语言 编程题.docx

《福建省高等学校计算机等级考试二级C语言 编程题.docx》由会员分享,可在线阅读,更多相关《福建省高等学校计算机等级考试二级C语言 编程题.docx(4页珍藏版)》请在冰豆网上搜索。

福建省高等学校计算机等级考试二级C语言 编程题.docx

福建省高等学校计算机等级考试二级C语言编程题

11.打开考生文件夹中的Cprog011.C,完成其中的函数fun1,该函数的数学表达式是:

例如:

fun1(0.76)=2.175

fun1(3.00)=5.307

fun1(3.76)=9.111

#include

#include

doublefun1(doublex)

{/**/

doublef;

f=(1+sin(x)+exp(x))/(1+x);

returnf;

/**/

}

voidmain()

{

clrscr();

printf("fun1(0.76)=%8.3lf\n",fun1(0.76));

printf("fun1(3.00)=%8.3lf\n",fun1(3.00));

printf("fun1(3.76)=%8.3lf\n",fun1(3.76));

}

12.打开考生文件夹中的Cprog012.C,完成其中的函数fun2(inta[],intn,intb[],intc[]),实现:

1)将数组a中大于-20的元素依次存放在数组b中;

2)将数组b中的元素按照从小到大的顺序依次存放到数组c中;

3)函数返回数组b中的元素个数。

#include

#include

#include

#include

intfun2(inta[],intn,intb[],intc[])

{/**/

intnb=0;

inti,j=0,temp;

for(i=0;i

if(a[i]>-20){b[j]=a[i];nb++;j++;}

for(i=0;i

for(i=0;i

for(j=0;j

if(c[j]>c[j+1])

{

temp=c[j];

c[j]=c[j+1];

c[j+1]=temp;

}

returnnb;

/**/}

voidmain()

{intn=10,i,nb;

intaa[10]={12,-10,-31,-18,-15,50,17,15,-20,20};

intbb[10],cc[10];

clrscr();

printf("Thereare%2delementsinaa.\n",n);

printf("Theyare:

");

for(i=0;i

printf("\n");

nb=fun2(aa,n,bb,cc);

printf("Elementsinbbare:

");

for(i=0;i

printf("\n");

printf("Elementsinccare:

");

for(i=0;i

printf("\n");

printf("Thereare%2delementsinbb.\n",nb);

}

21.打开考生文件夹中的Cprog021.C,完成其中的函数fun1,该函数的数学表达式使:

例如:

fun1(0.76)=3.582

fun1(3.00)=5.369

fun(3.76)=8.931

#include

#include

doublefun1(doublex)

{/**/

doublef;

f=(exp(x)+fabs(x-6))/(x+1.3);

returnf;

/**/

}

voidmain()

{

clrscr();

printf("fun1(0.76)=%8.3lf\n",fun1(0.76));

printf("fun1(3.00)=%8.3lf\n",fun1(3.00));

printf("fun1(3.76)=%8.3lf\n",fun1(3.76));

}

22.打开考生文件夹中的Cprog022.C,完成其中的函数fun2(chara[],charb[],charc[]),实现:

将三个字符串a、b、c从小到大排序后输出。

注意:

字符串比较函数为strcmp(str1,str2),

字符串赋值函数为strcpy(str1,str2)。

#include

#include

#include

#include

voidfun2(chara[],charb[],charc[])

{

/**/

chartemp[15];

if(strcmp(a,b)>0){strcpy(temp,a);strcpy(a,b);strcpy(b,temp);}

if(strcmp(a,c)>0){strcpy(temp,a);strcpy(a,c);strcpy(c,temp);}

if(strcmp(b,c)>0){strcpy(temp,b);strcpy(b,c);strcpy(c,temp);}

/**/

}

voidmain()

{charstr1[15]="Fuzhou",str2[15]="Fujian",str3[15]="China";

clrscr();

fun2(str1,str2,str3);

printf("Theorderedstringsis:

%s,%s,%s\n",str1,str2,str3);

getch();

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 唐诗宋词

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1