13
#include <iostream> #include <vector> int main() { using namespace std; int n; cout << "请输入一个整数: "; cin >> n; int *pt = new int[n]; pt[0] = n; cout << "new 创建动态数组完成\n" << "pt[0] = " << pt[0] << endl; delete[]pt; vector<int> m(n); m[0] = n; cout << "vector 创建动态数组完成\n" << "m[0] = " << m[0] << endl; system("pause"); return 0; }
15
#include <iostream> #include <cstring> struct fish { char type[20]; int weight; float length; }; int main() { using namespace std; fish *list = new fish; strcpy_s(list->type, 20, "鲫鱼"); list->weight = 45; list->length = 3.5; cout << "种类 重量[盎司] 长度[英寸]\n"; cout << list->type << " " << list->weight << " " << list->length << endl; delete list; system("pause"); return 0; }
hello world
@admin:
