第四章 复习题

来源:互联网 发布:linux个人目录 编辑:程序博客网 时间:2024/06/05 11:46

本博客所以复习题都是自己回答,不保证答案正确性,如有错误,欢迎指出


1.

a.char actor[30];

b. short betsie[100];

c. float chuck[13];

d. long double dipsea[64];


2. array<char, 30> actor;

array<short, 100> betsie;

array<float, 13> chuck;

array<long double, 64> dipsea;


3. int odds[5] = {1, 3, 5, 7, 9};


4. int even = odds[0] + odds[4];


5. cout << ideas[1];


6. char str_char[13] = "cheeseburger";


7. string str = "Waldorf Salad";


8. struct fish {

char kind[30];

int weight;

float length;

};


9. fish fish1 = {"samon", 5, 2.8};


10. enum Response {Yes = 1, No = 0, Maybe = 2};

Response re = Yes;


11. double ted = 10;

double *pted = &ted;

cout << *pted;


12. float treacle[10];

float *p_treacle = treacle;

cout << *p_treable << " " << *(p_treacle+9) << endl;


13. int n;

cin >> n;

int *arr_p = new int [n];

delete [] arr_p;

vector<int> arr_v(n);


14. 字符串”home of the jolly bytes" 第一个字母h所在内存的地址


15. fish * fish_p = new fish;

fish_p ->weight = 5;


16. 只能读取第一个空格之前的字符。


17. #include <array>

#include <vector>

#include <string>


int main() {

std::vector<std::string> vec_str(10);

std::array<std::string, 10> vec_arr;

...

}

0 0
原创粉丝点击