浙江大学c程2002B试卷E(2)
ch1=fgetc(f1);
ch2=fgetc(f2);
if(ch1!=ch2){
printf("%c#%c#",ch1,ch2);
printf("%d#", count);
break;
}
if(ch1=='?') count++;
}
fclose(f1);
fclose(f2);
}
《C Programming》TEST PAPER, June 20, 2003 6 /8
浙江大学c程2002B试卷E
Section 4: According to the specification, complete each program (2 mark for each blank, total: 30 marks)
1.If input is n(n>0), calculate the value of s = 1/1! + 1/2! + 1/3! + ……+ 1/n!.
#include <stdio.h>
void main( )
{ int j, k, n;
float f, s;
scanf("%d", &n);
;
for (k=1 ; k<=n; k++){
;
; j++)
;
s=s+1.0/f;
}
printf("sum=%f\", s);
}
(1) s=0
(2) f=1
(3) j<=k
(4)f=f*j
2.When input is n (n>0), if it’s a prime number, print "YES", otherwise print "NO". (Prime numbers: an integral number not divisible without a remainder by any integral number other than itself and one. One isn’t a prime number, but two is a prime number)。
#include <stdio.h>
#include <math.h>
void main( )
{
int n;
int prime(int m);
scanf("%d", &n);
)
printf("YES\n");
else
printf("NO\n");
}
《C Programming》TEST PAPER, June 20, 2003 7 /8
浙江大学c程2002B试卷E
int prime(int m)
{ int i,n;
if(m==1) return 0;
n=sqrt(m);
for(i=2; i<=n; i++)
;
;
}
(5) prime(n)
(6) m%i==0
(7) 0
(8)return 1
3.The definition of function f2 () is equivalent to the definition of function f1 ().
int f1(char s[ ]) int f2(char *s)
{ int k=0; { char *ss;
while(s[k]!='\0') ;
k++; return k; ;
} return ;
}
(9) ss=s
(10) ‘\0’
(11) s-ss-1
4.When input is the names and scores of 30 students, print the name and score of the student who have the highest score.
#include <stdio.h>
struct student{
char name[10];
int score;
};
void main( )
{
int k;
struct student s[30], *ptr;
struct student *f(struct student *stud, int n);
for(k=0; k<30; k++)
《C Programming》TEST PAPER, June 20, 2003 8 /8
浙江大学c程2002B试卷E
scanf("%s%d", s[k].name, &s[k].score);
printf("%s %d\n", ptr->name, ptr->score); }
struct student *f(struct student *stud, int n) {
struct student * pmax, *p;
;
for(p=stud; p<stud+n; p++)
if(p->score > pmax->score) return }
(12) ptr=f(s,30)
(13) pmax=stud
(14) pmax=p
(15) pmax
C Programming》TEST PAPER, June 20, 2003 9 /8 《
…… 此处隐藏:34字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [幼儿教育]【完整版】2019-2025年中国药物发现外
- [幼儿教育]2018-2019年初中信息技术广东初一竞赛
- [幼儿教育]最新外研版(一起)小学英语五年级上册《
- [幼儿教育]农业推广与创新管理专业 -中农大毕业论
- [幼儿教育]2017-2022年中国更年期用药行业市场深
- [幼儿教育]数学1.1.2第1课时棱柱、棱锥和棱台的结
- [幼儿教育]二年级群文阅读课例欣赏
- [幼儿教育]2010-2015年中国保险行业投资分析及深
- [幼儿教育]厄运打不垮的信念第一课时
- [幼儿教育]巧用文本,让表达在言语中绽放论文
- [幼儿教育]中学生百科知识竞赛题及答案
- [幼儿教育]八大菜系英文简介
- [幼儿教育]中国男装牛仔裤市场发展研究及投资前景
- [幼儿教育]远程数字视频监控系统在银行的应用
- [幼儿教育]光纤光缆制造工艺及设备
- [幼儿教育]国家安全法试题及答案
- [幼儿教育]2011高中提前招生及竞赛试题(物理卷1)
- [幼儿教育]宁夏第三产业房地产业、科学研究和技术
- [幼儿教育]中兴通讯 ME3000模块用户硬件设计手册_
- [幼儿教育]紫外线灯管的辐照强度问题
- 苏联东欧剧变的原因和历史教训浅析
- 人工智能导论实验报告(学生)
- 思科ITE章考试原题及答案
- 《学习雷锋好榜样》主题班会教案
- 加油站建设项目安全评价报告
- 剖析社保卡管理系统
- 2017-2018年影视剧新媒体版权运营行业
- 2017-2018学年四川省成都市高一上学期
- 2019最新高中数学 第三章 3.2.1 几类不
- 2011-2015年中国基酸市场调查及行业前
- 人教版新课标选修八Unit 1 课件Warming
- 郭溪燎原小学辅导学生记录表
- 教师资格证统考综合素质写作秘笈
- 国外校园绿色建筑研究方向与建设实践
- 15.1 动物运动的方式 课件(北师大版八
- 民用飞机空调系统
- 长安侠文化传统与唐诗的任侠主题
- 《中国近现代史纲要》名词解释
- 11金本《保险学概论》复习资料
- 民用建筑机电安装工程专业施工图图纸会




