第一章
一、单项选择题
1. B (typedef ,typeid ,typename,都为关键字(保留字);
2. C 
3. C
二、填空题
1.cin  cout
2.new  delete
3.new int[55];  分配内存格式:new 数据类型[size]  申请可以存储size个该数据类型的对象
三、改错题
1.分析如下主程序中的错误
void main()
{
    int num(50);  //需要先声明num变量,并初始化
    int& ref = num;
    ref = ref +100;
    num = num + 50;
}
2. 分析如下主程序中的错误
void main()
{
    int x=58, y=98;
    const int *p=&x; 
    y = *p;
    *p = 65;  //*p是声明指向常量的指针,*p不能作为左值,故*p = 65;错误
    p = &y;
}
3. 分析如下主程序中的错误
void main()
{
    int x=58, y=98, z=55;
    int * const p=&x;
    *p = 65; 
    p = &y;  //p是声明为常量指针,p不能作为左值,故p = &y;错误
    x = 65;
    z = *p;
}
四、编程题(可直接复制到VC++ 6.0 运行
1. 分别用字符和ASCII码形式输出整数值65和66.
#include <iostream>
using namespace std;
void main()
{
float型
    char ch1='A', ch2='B'; 
//字符'A'对应的整数值是65,'B'对应66
    int  ascii_5=53, ascii_6=54;
//数字5对应的ASCII码是53,数字6对应54
    cout << "字符形式输出:" << (int)ch1 << "," << (int)ch2 <<endl;
    cout << "ASCII码形式输出:"<<(char)ascii_6<<(char)ascii_5 << ","
        << (char)ascii_6 << (char)ascii_6 << endl;
}
2.编写一个int型变量分配100个整形空间的程序。
#include < iostream >
using namespace std;
void main()
{
    int *p;    //int型指针变量,
    p = new int[100]; //指针变量指向可以存储100整型的空间
}
3.编写完整的程序,它读入15个float值,用指针把它们存放在一个存储快里,然后输出这些值和以及最小值。
#include <iostream>
#include <algorithm> //用于数组操作的头文件,参照课本P13-P14
using namespace std;
void main()
{
    float *p = new float[15];  //分配15个可存储float型的存储空间
    float sum=0;            //用于求和,初始化为0
    cout<<"输入15个float类型的值:" << endl; //提示输入float数值
    for(int i=0; i<15; i++) 
    {
        cin >> *(p+i);        //一个个输入
        sum = sum + *(p+i);  //求和
    }
    sort(p,p+15);        //由小到大排序(升幂排序)
    cout << "这些值的和:" << sum << endl;    //输出和
    cout << "这些值的最小值:" << *p << endl;
//输出最小值(排序后第一个值最小)
    delete p;  //释放内存
}
4.声明如下数组:
int a[] = {1 ,2 ,3, 4, 5, 6, 7, 8};
先查4的位置,讲数组a复制给数组b,然后将数组a的内容反转,再查4的位置,最后分别输出数组a和b的内容。
#include <iostream>
#include <algorithm> //用于数组操作的头文件,参照课本P13-P14
#include <functional>
using namespace std;
void main()
{
    int a[] = {1, 2, 3, 4, 5, 6, 7, 8}, b[8]={0};
    copy(a,a+8,ostream_iterator<int>(cout," "));  //输出数组a
    cout << endl;
    cout << "数字4位于数组的第 " << *find(a,a+8,4) << "位" << endl;
    //查数字4的位置
    copy(a,a+8,b);  //复制数组a到b
    copy(b,b+8,ostream_iterator<int>(cout," "));  //输出数组b
    cout << endl;
    reverse(a,a+8);  //将数组a的内容反转
    copy(a,a+8,ostream_iterator<int>(cout," "));  //输出数组a
    cout << endl;
    cout << "数字4位于数组的第 " << *find(a,a+8,4) << "位" << endl;
    //再查数字4的位置
}