文档详情

C++题库C++题库.doc

发布:2017-01-01约15.54万字共228页下载文档
文本预览下载声明
试卷编号:9476 所属语言:C++ 试卷方案:C++_lx1 试卷总分:1440分 共有题型:1种 ━━━━━━━━━━━━━━━━━━ 一、程序设计 共144题 (共计1440分) ━━━━━━━━━━━━━━━━━━ 第1题 (10.0分) 题号:268 /*------------------------------------------------ 【程序设计】 -------------------------------------------------- 题目: 找出1-200之间的完数个数 n(完数是一个数的因 子之和是这个数本身。例如6=1+2+3)。 -------------------------------------------------- 注意:部分源程序给出如下。请勿改动主函数main和其它 函数中的任何内容,仅在函数的花括号中填入所编 写的若干语句。 ------------------------------------------------*/ #include iostream.h #include fstream.h #include stdio.h void writeinfile(int n); void main() { int m,n,k,s,l; n=0; for(m=1;m=200;m++) {s=1; for(l=2;lm;l++) if(m%l==0)s+=l; if(m==s){n++;coutm;} } writeinfile(n); } void writeinfile(int n) { fstream myfile; myfile.open(f.txt,ios::out); myfilenendl; myfile.close(); } 答案:---------------------- ---------------------- 第2题 (10.0分) 题号:580 /*------------------------------------------------ 【程序设计】 -------------------------------------------------- 题目:在一维数组中分类统计正数和负数的个数。 正数的个数存入变量C1中,负数个数存入变量C2中. -------------------------------------------------- 注意:部分源程序给出如下。请勿改动主函数main和其它 函数中的任何内容,仅在函数的花括号中填入所编 写的若干语句。 ------------------------------------------------*/ #includefstream #includeiostream using namespace std; void wwjt(int ,int ); void main() { int a[10]={1,-2,0,4,-5,0,7,8,-9,10}; int c1=0,c2=0; int i; for (i=0; i10; i++) if (a[i]0) c1++; else if (a[i]0) c2++; wwjt(c1,c2); } void wwjt(int o,int p) { fstream myfile; myfile.open(out.txt,ios::out); myfileoendlp; myfile.close(); } 答案:---------------------- ---------------------- 第3题 (10.0分) 题号:582 /*------------------------------------------------ 【程序设计】 -------------------------------------------------- 题目:在包含10个数的一维整数数组a中查找最大元素max 和最小元素min。 -------------------------------------------------- 注意:部分源程序给出如下。请勿
显示全部
相似文档