下载此文档

c上机题目套.docx


文档分类:IT计算机 | 页数:约19页 举报非法文档有奖
1/19
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/19 下载此文档
文档列表 文档介绍
公司内部档案编码:[OPPTR-OPPT28-OPPTL98-OPPNN08]
c上机题目套
一、程序填空题
考试做题要求:
1、在__1__处填写正确的答案,并将下划线和数字删除。
2、将题目做完之后一定要保存。
3、不能删除/**********found**********/,也不能多行或少行。
1、请补充fun函数,fun函数的功能是求m的阶乘。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
# include <>
long fun(int m)
{
if(___1___)
return (m*fun(___2___));
return ___3___;
}
main()
{
printf("8!=%ld\n",fun(8));
}
2、请补充fun函数,该函数的功能是:判断一个年份是否为闰年。
例如,2007年不是闰年,2008是闰年。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
# include <>
# include <>
int fun(int n)
{
int flag=0;
if(n%4==0)
if(____1_____)
flag=1;
if(____2____)
flag=1;
return ___3____;
}
main()
{
int year;
printf("Input the year:");
scanf("%d",&year);
if(fun(year))
printf("%d is a leap year.\n",year);
else
printf("%d is not a leap year.\n",year);
}
3、函数fun的功能是:从三个形参x、y、z中找出中间的那个数,作为函数值返回。
例如,当x=121,y=456,z=333时,中间的数为333。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
# include <>
int fun(int a,int b,int c)
{
int temp;
temp=(a>b) (b>c b : (a>c c : ___1___)) :
((a>c) ___2___ :
((b>c) c : ___3___));
return temp;
}
main()
{
int x=121,y=456,z=333,mid;
mid=fun(x,y,z);
printf("\nThe middle number is : %d\n",mid);
}
4、请补充函数fun(char *t),该函数的功能是把字符串中的内容逆置。
例如,字符串中原有的字符串为ABCDE,则调用该函数后,串中的内容为EDCBA。
请勿改动主函数main与其他函数中的任何内容,仅在fun函数的横线上填写所需的若干表达式或语句。
注意:部分源程序给出如下。
# include <>
# include <>
# include <>
# define M 60
void fun(char *t)
{
int j,m=strlen(t)-1;
char s;
for(j=0;j<m;j++,___1___)
{
s=t[j];
___2___;
___3___;
}
}
main()
{
char b[M];
printf("Input a string:");
gets(b);
printf("The original string is:");
puts(b);
fun(b);
printf("\n");
printf("The reversal string :");
puts(b);
}
5、请补充main函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。例如,输入:-666,结果为:666。
仅在横线上填写所需的若干表达式或语句,请勿改动函数中的其他任何内容。
注意:部分源程序给出如下

c上机题目套 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数19
  • 收藏数0 收藏
  • 顶次数0
  • 上传人YL01
  • 文件大小231 KB
  • 时间2021-06-17