c++怎么考,科目四考什么题型型

导读: 2018年9月全国计算机二级预计6月报名,那二级开考科目都考什么内容你知道吗?
根据,全国计算机二级C++考试内容主要包括:C++语言概述,数据类型、表达式和基本运算,C++的基本语句,数组、指针与引用,掌握函数的有关使用等10大内容。考试形式为上机考试,考试时长120分钟,满分100分。具体内容如下:一、C++语言概述1. 了解 C++语言的基本符号。2. 了解 C++语言的词汇(关键字、标识符、常量、运算符、标点符号等)。3. 掌握 C++程序的基本框架。4. 能够使用 Visual C++ 2010 学习版集成开发环境编辑、编译、运行与调试程序。二、数据类型、表达式和基本运算1. 掌握 C++数据类型(基本类型,指针类型)及其定义方法。2. 了解 C++的常量定义(整型常量,字符常量,逻辑常量,实型常量,地址常量,符号常量)。3. 掌握变量的定义与使用方法(变量的定义及初始化,全局变量,局部变量)。4. 掌握 C++运算符的种类、运算优先级和结合性。5. 熟练掌握 C++表达式类型及求值规则(赋值运算,算术运算符和算术表达式,关系运算符和关系表达式, 逻辑运算符和逻辑表达式,条件运算,指针运算,逗号表达式)。三、C++的基本语句1. 掌握 C++的基本语句,例如赋值语句、表达式语句、复合语句、输入、输出语句和空语句等。2. 用 if 语句实现分支结构。3. 用 switch 语句实现多分支选择结构。4. 用 for 语句实现循环结构。5. 用 while 语句实现循环结构。6. 用 do...while 语句实现循环结构。7. 转向语句(goto,continue,break 和 return)。8. 掌握分支语句和循环语句的各种嵌套使用。四、数组、指针与引用1. 掌握一维数组的定义、初始化和访问,了解多维数组的定义、初始化和访问。2. 了解字符串与字符数组。3. 熟练掌握常用字符串函数(strlen,strcpy_s,strcat_s,strcmp,strstr 等)。4. 指针与指针变量的概念,指针与地址运算符,指针与数组。5. 引用的基本概念,引用的定义与使用。五、掌握函数的有关使用1. 函数的定义方法和调用方法。2. 函数的类型和返回值。3. 形式参数与实际参数,参数值的传递。4. 变量的作用域和生存周期。5. 递归函数。6. 函数重载。7. 内联函数。8. 带有默认参数值的函数。六、熟练掌握类与对象的相关知识1. 类的定义方式、数据成员、成员函数及访问权限(public,private,protected)。2. 对象和对象指针的定义与使用。3. 构造函数与析构函数。4. 静态数据成员与静态成员函数的定义与使用方式。5. 常数据成员与常成员函数。6. this 指针的使用。7. 友元函数和友元类。8. 对象数组与成员对象。七、掌握类的继承与派生知识1. 派生类的定义和访问权限。2. 继承基类的数据成员与成员函数。3. 基类指针与派生类指针的使用。4. 虚基类。5. 子类型关系。八、了解多态性概念1. 虚函数机制的要点。2. 纯虚函数与抽象基类,虚函数。3. 了解运算符重载。九、模板1. 简单了解函数模板的定义和使用方式。2. 简单了解类模板的定义和使用方式。十、输入输出流1. 掌握 C++流的概念。2. 能够使用格式控制数据的输入输出。3. 掌握文件的 I / O 操作。报名关注:领先备考:计算机名师辅导,30小时高效提分,150元快速取证,通关计划:
海量免费模拟试题,在线测试。
各科每年真题试卷,实战演练!
逐章逐节针对练习,专项突破。
每天10道最新试题,随机练习。
随时掌握考试动态C++常见笔试题及答案_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C++常见笔试题及答案
阅读已结束,下载本文需要
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩61页未读,
定制HR最喜欢的简历
你可能喜欢有么有谁知道C++考什么题型啊?重点是什么哇?!!【西南交通大学吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:436,469贴子:
有么有谁知道C++考什么题型啊?重点是什么哇?!!收藏
一学期书都还是新的,表示压力很大…
背课后习题吧,骚年.
是题型是课后,还是说原题?
偶们 老师说
题目都在书中
书中都是题目 大概原题会有一半吧至少。。。所以背书吧。。
很多基础小知识
没有课后原题
额 五十分的选择题 表示压力很大~~
- -肿么办啊
加群海量学习资源
登录百度帐号43853 条评论分享收藏感谢收起赞同 20915 条评论分享收藏感谢收起C++期末复习练手题
1 . 输出字符 ‘A’ 和 ‘a’ 的ASCII码值。
#include &iostream&
using namespace std;
int main()
cout&&"ASCII of 'A'="&&i&&endl&&"ASCII of 'a'="&&j&&
ASCII of ‘A’=65
ASCII of ‘a’=97
2 . 输入两个小写字符,将其转换为大写
#include &iostream&
using namespace std;
int main()
char c1,c2;
cout&&"input two char: ";
cin&&c1&&c2;
cout&&"c1="&&c1&&endl&&"c2="&&c2&&
输入:input two char: lc
3.输入两个浮点型数字,但要求输出的是整型
#include &iostream&
using namespace std;
int main()
float c1,c2;
cout&&"input two float: ";
cin&&c1&&c2;
c1=(int)c1;
c2=int(c2);
cout&&"c1="&&c1&&endl&&"c2="&&c2&&
输入:input two char: 3.97 7.56
4.【密码编译题】输入字符串”CHINA”, 每个字母往后加4个ASCII字符后
#include &iostream&
using namespace std;
int main()
char a[6];
for(int i=1;i&6;i++)
cin&&a[i];
a[i]=a[i]+4;
for(int i=1;i&6;i++)
cout&&a[i];
输入:CHINA
输出:GLMRE
5 . 输出整数179的十六进制和八进制表达结果。
#include &iostream&
using namespace std;
int main()
int a=179;
cout&&"hex="&&hex&&a&&endl&&"oct="&&oct&&a&&
6 . 控制符下的输出
#include &iostream&
#include &iomanip&
using namespace std;
int main()
int a=179;
cout&&setfill('+')&&setw(10)&&a&&
输出:+++++++179
7.单个字符的输入输出
#include &iostream&
using namespace std;
int main()
a=getchar();.
putchar(c);
putchar(10);
8 . if的嵌套
在if的嵌套中,也可以加花括号来表示层级匹配关系,特别是在if与else数目不一样的情况下:
{if() 语句1}
else 语句2
9 . 判断某年是否为闰年
#include &iostream&
using namespace std;
int main()
cout&&"input the year:";
if ((year%400==0)||(year%100!=0 && year%4==0))
cout&&year&&"is leap year"&&
else cout&&year&&" is not leap year"&&
输入:input the year:1900
输出:1900 is not leap year
10.【递归】用递归方法求n阶勒让德多项式的值,递归公式见书p123,习题8。
#include &iostream&
using namespace std;
int main()
double Legendre(double x,int n);
cout&&"input the value of x: "; cin&&a;
cout&&"input the value of n: "; cin&&b;
cout&&"the value of "&&b&&"-class "&&"Legendre is: "&&Legendre(a,b)&&
double Legendre(double x,int n)
if(n==0) lgd=1;
else if (n==1) lgd=x;
else lgd=((2*n-1)*x*Legendre(x,n-1)-(n-1)*Legendre(x,n-2))/n;
11.【函数嵌套】写一个函数验证哥德巴赫猜想:一个不小于6的偶数可以表示为两个素数之和,如10=3+7,在主函数中输入一个不小于6的偶数,然后调用函数gotbaha,在gotbaha函数中再调用prime函数,prime函数用于判断是否素数。
#include &iostream&
#include &cmath&
using namespace std;
int main()
int gotbaha(int );
cout&&"input the even number y: ";
gotbaha(a);
int gotbaha(int y)
int prime(int );
for (int i=2;i&=ceil(y/2);i++)
if (prime(i) && prime(j))
cout&&y&&"="&&i&&"+"&&j&&
int prime(int x)
bool pr=true;
for (int i=2;i&x;i++)
if (x%i==0) pr=false;
输入:input the even number y: 34
输出:34=3+31
12 . 【函数调用】
#include &iostream&
#include &cmath&
using namespace std;
int main()
int area(int ,int ,int );
int x,y,z;
cout&&"input the 3 edges: ";
cin&&x&&y&&z;
if (x+y&z && x+z&y && y+z&x)
cout&&"area="&&area(x,y,z)&&
else cout&&"it is not a triangle"&&
int area(int a,int b,int c)
s=(a+b+c)/2;
ar=sqrt(s*(s-a)*(s-b)*(s-c));
13 . 【阶乘的递归实现】求a!+b!+c!的值,用一个函数fact(n)求n!。a,b,c的值由主函数输入,最终得到的值在主函数中输出。
#include &iostream&
using namespace std;
int main()
int fact(int n);
int a,b,c,
cin&&a&&b&&c;
sum=fact(a)+fact(b)+fact(c);
int fact(int n)
if(n==1) f=1;
else f=fact(n-1)*n;
14 . 【while循环 · 迭代法】用牛顿迭代法求方程的根。方程为
ax^3+bx^2+cx+d=0,系数a,b,c,d的值依次为4,3,2,1,由主函数输入。求x在1附近个一个实根。求出根后由主函数输出。
注:牛顿迭代法公式:x2=x1-f1/f2
//心得:往往写while循环都在循环体外和循环体内把函数写两遍
int main()
double newton(int a,int b,int c,int d);
cout&&newton(4,3,2,1)&&
double newton(int a,int b,int c,int d)
double f1,f2,x,x1,x2,m;
f1=a*x1*x1*x1+b*x1*x1+c*x1+d;
f2=3*a*x1*x1+2*b*x1+c;//f2是f1的导数
x1=1; //赋一个初值,随便找一个值开始
x2=x1-f1/f2;//迭代关键
while(abs(x1-x2)&0.00001) //结束循环的条件
f1=a*x1*x1*x1+b*x1*x1+c*x1+d;
f2=3*a*x1*x1+2*b*x1+c;
x2=x1-f1/f2;
return x2;
#include &iostream&
using namespace std;
int main()
while((c=getchar())!='\n')
if(('z'&=c && c&='w') || ('Z'&=c && c&='W')) c=c-22;
if(('v'&=c && c&='a') || ('W'&=c && c&='A')) c=c+4;
输入:I am going to Beijing!
输出:M eq ksmrk xs Fimnmrk!
16 . 【循环应用题】猴子当天吃掉的桃子数为前一天剩下桃子数的一半再多一个,到第10天时,只剩下一个桃子了,求:第一天的桃子数
分析:写出通项公式是关键
S1-1/2*S2-1=S2,设S1为前一天所剩桃子数,S2为当天所剩桃子数
==&S1=2*S2+2
#include &iostream&
using namespace std;
int main()
int s=1,n=1;
while(n&10)
有3个国家名,要求找出按字母顺序排在最前面的国家。要求用函数调用。
#include &iostream&
#include &string&
using namespace std;
int main()
void stringcmp(char string[][]);
char str[4][20];
for(int i=1;i&4;i++)
cin&&str[i];
stringcmp(str);
void stringcmp(char string[][])
char min[20];
strcpy(min,string[1]);
for(int i=1;i&3;i++)
if(strcmp(string[i+1],min)&0)
strcpy(min,string[i+1]);
cout&&min&&
输入:GERMANY FRANCH CHINA
输出:CHINA
18 . 逆序输出CHINA
#include &iostream&
#include &string&
using namespace std;
int main()
char word[6];
for(int i=1;i&6;i++)
cin&&word[i];
while(n!=0)
cout&&word[len];
输入:CHINA
输出:ANIHC
19 . 10个数选择排序法(从大到小)
1) 外循环执行n-1次,内循环每次比较和交换n-i次(i为第i次外循环)
2) 从数组第一位开始循环,后面从第二个元素开始直到访问完数组中最后一个元素为止,遇到最小值则与之交换;然后进行第二次循环,从数组第二个元素开始,从第三个元素开始访问之后的所有元素,遇到最小值则与之交换……
#include &iostream&
using namespace std;
int main()
void quicksort(int b[]);
int a[11];
cout&&"input 10 numbers: ";
for(int i=1;i&11;i++)
cin&&a[i];
quicksort(a);
for(int i=1;i&11;i++)
cout&&"sorted array: "&&a[i]&&
void quicksort(int b[])
for (int i=1;i&10;i++)
int max=b[i],m=i;
for (int j=(i+1);j&11;j++)
if (b[j]&max)
b[m]=b[i];
20 . 折半查找(二分查找)
given:一个由大到小排好序的10个元素的数组
求:输入一个元素,查找该元素在数组中位置,即索引
step1: 每次从数组的中间元素开始找起
step2: 然后根据目标数字与中间元素的大小关系,锁定该中间元素的左区间或右区间
step3:重复步骤2,直至目标元素=中间元素
#include &iostream&
#include &cmath&
using namespace std;
int main()
void binary_search(int t,int b[],int n);
int a[11]={0,20,19,17,15,9,6,5,3,2,1},len=10;
cout&&"input a number that you want to search: ";
binary_search(target,a,len);
void binary_search(int t,int b[],int n)
int lb=1,ub=10,
bn=ceil((lb+ub)/2);
while(b[bn]!=t)
if (t&b[bn])
bn=ceil((lb+ub)/2);
bn=ceil((lb+ub)/2);
cout&&"the index of this item is: "&&bn&&
21 . 找一个五个元素数组中的第二大的值
#include &iostream&
using namespace
int main()
int a[6]={0,1,2,3,4,5};
int max=a[1],sec=a[1];
for (int i=2;i&6;i++)
if (max&a[i]) max=a[i];
for (int i=2;i&6;i++)
if (sec&a[i] && a[i]&max) sec=a[i];
cout&&"max="&&max&&" , sec="&&sec&&
22 . 生成随机整数
#include &iostream&
using namespace std;
int main()
for (int i=1;i&11;i++)
x=(rand()%10)+1;
cout&&x&&" ";
#include &iostream&
using namespace std;
int main()
for (int i=1;i&11;i++)
x=(rand()%11);
cout&&x&&" ";
23 . 分解质因数
#include &iostream&
using namespace std;
int main()
void prime_factor(int b);
cout&&"input a number: ";
prime_factor(a);
void prime_factor(int b)
for (int i=2;i&=b;i++)
while (b%i==0)
cout&&i&&" ";
最大公因数gcd和最小公倍数lcm
#include &iostream&
using namespace std;
int main()
void gcd_lcm(int m,int n);
cout&&"input two number: ";
cin&&a&&b;
gcd_lcm(a,b);
void gcd_lcm(int m,int n)
int de,gcd,lcm,
while(m%n!=0)
cout&&"gcd="&&gcd&&" lcm="&&lcm&&
25 . 重载之复数加法
#include &iostream&
using namespace std;
class complex
complex (int a=0,int b=0);
friend complex operator+(complex n1,complex n2);
void display();
complex::complex (int a,int b)
complex operator+(complex n1,complex n2)
complex n3;
n3.real=n1.real+n2.
n3.imag=n1.imag+n2.
return n3;
void complex::display()
cout&&"("&&real&&","&&imag&&"i"&&")"&&
int main()
complex c1(3,4),c2(5,6),c3;
cout&&"c3=";
c3.display();
26 . 重载之复数乘法
#include &iostream&
class complex
complex(int a=0,int b=0);
friend complex operator*(complex n1,complex n2);
void display();
int real,imag;
complex::complex(int a,int b)
complex operator*(complex n1,complex n2)
complex n3;
n3.real=n1.real*n2.real-n1.imag*n2.imag;
n3.imag=n1.real*n2.imag+n1.imag*n2.real;
return n3;
void complex::display()
cout&&"("&&real&&","&&imag&&"i)"&&
int main()
complex c1(3,4),c2(5,6),c3;
cout&&"c3=";
c3.display();
27、定义一个具有26个下标变量的字符数组,初始值为”A”到”Z”的26个英文字母,用户从键盘输入 任意4个数(1到26之间,表示对应字符的位置),显示对应序号上的字符。例如输入1 3 2 4,显示 ACBD。
#include &iostream&
using namespace std;
int main()
char b[4];
cout&&"input 4 numbers: ";
for(int i=0;i&4;i++)
cin&&a[i];
b[i]=a[i]+64;
cout&&b[i]&&" ";
28 . 自定义一个函数(VB)或类的方法(JAVA、C++),功能:按两个参数(直角三角形的直角 边的长度)的值,计算并返回三角形的面积值。再定义一个程序,功能:从键盘输入两个数(直 角三角形的直角边的长度),调用上述自定义函数或方法,计算并输出三角形的面积值。
有一个小小的心得:如果想要用成员函数传递参数时,这时候就不要写成员函数了,直接写构造函数就好了,当然,如果不要传递参数,那么成员函数还是可以用的。
方法一:无参的成员函数,无构造函数
#include &iostream&
using namespace std;
void tr();
void area();
int edge1,edge2;
void t::tr()
cout&&"input two edges: ";
cin&&a&&b;
edge1=a;edge2=b;
void t::area()
ta=(edge1*edge2)/2;
cout&&"the area of the triangle is: "&&ta&&
int main()
t1.area();
方法二:定义构造函数,带参数
#include &iostream&
using namespace std;
t(int a=0,int b=0);
void area();
int edge1,edge2;
t::t(int a,int b)
cout&&"input two edges: ";
cin&&a&&b;
edge1=a;edge2=b;
void t::area()
ta=(edge1*edge2)/2;
cout&&"the area of the triangle is: "&&ta&&
int main()
t1.area();
从键盘上输入任意6个整数,分别计算并显示出奇、偶数的和。
#include &iostream&
using namespace std;
int main()
int a[6],even=0,odd=0;
cout&&"input 6 integers: ";
for(int i=1;i&7;i++)
cin&&a[i];
if (a[i]%2==0) even=even+a[i];
else odd=odd+a[i];
cout&&"sum of even is: "&&even&&endl&&"sum of odd is: "&&odd&&
30 . 找出并显示出1-200之间所有能被7整除但不能被5整除的整数。
代码一:什么格式都不控制
#include &iostream&
#include &iomanip&
using namespace std;
int main()
for(int i=1;i&200;i++)
if(i%7==0 && i%5!=0) cout&&i&&" ";
#include &iostream&
#include &iomanip&
using namespace std;
int main()
for(int i=1;i&200;i++)
if(i%7==0 && i%5!=0)
cout&&i&&setw(2)&&" ";
if (s%5==0) cout&&
31、用户从键盘上输入一组整数(a1,a2,…,a10)和另一组整数(b1,b2,…,b10),假设这两组整数中的每 一个整数的取值范围为0-30(包含0和30),计算并显示a1*b10+a2*b9+a3*b8+…+a10*b1和 a1*b1+a2*b2+a3*b3+…+a10*b10的值。
#include &iostream&
using namespace std;
int main()
int sum1(int m[],int n[],int len);
int sum2(int m[],int n[],int len);
int a[6],b[6];
cout&&"input array a[]: ";
for (int i=1;i&6;i++) cin&&a[i];
cout&&"input array b[]: ";
for (int i=1;i&6;i++) cin&&b[i];
cout&&"sum1="&&sum1(a,b,5)&&
cout&&"sum2="&&sum2(a,b,5)&&
int sum1(int m[],int n[],int len)
int ss1[len+1],s=0;
for(int i=1;i&(len+1);i++)
ss1[i]=m[i]*n[len-i+1];
s=s+ss1[i];
int sum2(int m[],int n[],int len)
int ss2[len+1],s=0;
for(int i=1;i&(len+1);i++)
ss2[i]=m[i]*n[i];
s=s+ss2[i];
32、计算并显示1-2-3+4-5-6+7-8-9+…n的值。其中n为程序运行时用户从键盘上输入的一个100-200 之间的整数。
#include &iostream&
using namespace std;
int main()
int n,s=0,j;
cout&&"input a number(100~200): ";
for(int i=1;i&(n+1);i++)
if (i%3==0 || (i+1)%3==0)
cout&&"the sum is: "&&s&&
33 . 编写一个函数(或者是方法),其功能为:用户从键盘上输入一个字符串,输出该字符串的 第3个字符。
#include &iostream&
#include &string&
using namespace std;
int main()
cout&&"input a string: ";
cout&&"the third item of this string is:"&&word[2]&&
C++ 复习(菜鸟教程中的C++)
c++期末考试复习总结
清华大学计算机系C++期末考试题及答案
【c++主题】一套不错的考试题
C++期末考试题
没有更多推荐了,

我要回帖

更多关于 小考题型 的文章

 

随机推荐