1.char actors [30]
short betsize [100]
float chuck[13]
long double dipsea [64]
2.array <char,30> actors
array <short,100> betsize
array <float,13> chuck
array <long double,64> dipsea
3. int Odd[5] = {1,3,5,7,9} or int Odd[5] {1,3,5,7,9}(列表初始化)
4. int Even = Odd[0] + Odd[4]
5. float ideas [3] = {3.14,3.15,3.16};
cout << ideas[1] << endl;
6.char Food[] = “cheeseburger”
7.string Food = “WaldorfSalad”
8.struct Fish {char kind[30];int weight;float length};
9.Fish Petes = {“Trout”,12,26.25}
10.enum Response = {‘Yes’ = 1 ;‘No’ = 0 ; ‘Maybe’ = 2}xxxxxx
enum Response {No,Yes,Maybe};
11.double Ted = 3.14;
double *p = &Ted;
cout << *p << endl;
12.float *p = treacle[];xxxx
float *p = treacle ;
cout << pf[0] << “and” << pf[9]<< endl;
13. cout << "Enter a Size " << endl;
cin >> Size ;
int p = new int [Size] ;
vector arr(size);
14. 打印字符串的地址 不会打印字符串
15. struct Fish{
char Kind[30];
int Weight;
float length;
}
Fish *p = new Fish;
cout << "Enter the kind of fish " << endl;
cin >> p -> Kind
16.lge
c++ primer plus 第四章
最新推荐文章于 2025-05-07 21:53:58 发布