第四章 复习题P123

#include<iostream>
#include<array>
#include<vector>

int main(){
    // ini
    using namespace std;
    cout.setf(ios_base::fixed,ios_base::floatfield);
    // starts
    // 1
    char actor[30]; 
    short betsie[100];
    float chuch[13];
    long double dipsea[64];
    // 2
    array<char,30> actor1; 
    array<short,100> betsie1;
    array<float,13> chuch1;
    array<long double,64> dipsea1;
    // 3
    int ji[5]={1,3,5,7,9}; 
    // 4
    int even;
    even = ji[0]; 
    even = ji[4];
    // 5
    float ideas[4] = {0,2.1,3.4,5.55}; 
    cout<<ideas[1]<<endl;
    // 6
    char cheese[13] = "cheeseburger"; 
    // 7
    string wald = "Waldof Salad"; 
    // 8
    struct fish{
        char variety[20];
        int weight;
        double length;
    };  // 结构体声明后别忘记加“;”
    // 9
    fish butterfish = {"butterfish",10,22.5};
    // 10
    enum Response{Yes=1,No=0,Maybe=2};
    // 11
    double ted = 2.45;
    double *p = &ted;
    cout<<*p<<endl;
    // 12
    float treacle[10]={1.1,0,0,0,0,0,0,0,0,9.9};
    float *p1 = &treacle[0]; // float *p1 = treacle;
    cout<<*p1<<" "<<*(p1+9)<<endl;
    // 13
    cout<<"请输入一个正整数:";
    int n;
    cin>>n;
    int *a1 = new int[n];
    vector<int> a2(n);
    // 14  输出该字符串首地址
    cout<<(int*) "Home of the jolly bytes"<<endl;
    // 15
    fish *f1 = new fish;
    cout<<"input variety:"<<endl;
    cin>>f1->variety;    
    cout<<"input weight:"<<endl;
    cin>>f1->weight;
    cout<<"input length:"<<endl;
    cin>>f1->length;
    cout<<"variety: "<<f1->variety<<"\n"<<"weight: "<<f1->weight<<"\n"<<f1->length<<endl;
    // 16  输入不再因换行出问题
    int year;
    cin>>year;
    char address[80];
    cin>>address;
    cout<<year<<endl;
    cout<<address<<endl;
    // 17
    const int num = 10;
    std::vector<string> s1(num);
    std::array<string,num> s2;

    // getchar();
    // getchar();
    return 0;
}

#include
#include
#include

int main(){
// ini
using namespace std;
cout.setf(ios_base::fixed,ios_base::floatfield);
// starts
// 1
char actor[30];
short betsie[100];
float chuch[13];
long double dipsea[64];
// 2
array<char,30> actor1;
array<short,100> betsie1;
array<float,13> chuch1;
array<long double,64> dipsea1;
// 3
int ji[5]={1,3,5,7,9};
// 4
int even;
even = ji[0];
even = ji[4];
// 5
float ideas[4] = {0,2.1,3.4,5.55};
cout<<ideas[1]<<endl;
// 6
char cheese[13] = “cheeseburger”;
// 7
string wald = “Waldof Salad”;
// 8
struct fish{
char variety[20];
int weight;
double length;
}; // 结构体声明后别忘记加“;”
// 9
fish butterfish = {“butterfish”,10,22.5};
// 10
enum Response{Yes=1,No=0,Maybe=2};
// 11
double ted = 2.45;
double *p = &ted;
cout<<*p<<endl;
// 12
float treacle[10]={1.1,0,0,0,0,0,0,0,0,9.9};
float *p1 = &treacle[0]; // float *p1 = treacle;
cout<<p1<<" "<<(p1+9)<<endl;
// 13
cout<<“请输入一个正整数:”;
int n;
cin>>n;
int a1 = new int[n];
vector a2(n);
// 14 输出该字符串首地址
cout<<(int
) “Home of the jolly bytes”<<endl;
// 15
fish *f1 = new fish;
cout<<“input variety:”<<endl;
cin>>f1->variety;
cout<<“input weight:”<<endl;
cin>>f1->weight;
cout<<“input length:”<<endl;
cin>>f1->length;
cout<<“variety: “<variety<<”\n”<<“weight: “<weight<<”\n”<length<<endl;
// 16 输入不再因换行出问题
int year;
cin>>year;
char address[80];
cin>>address;
cout<<year<<endl;
cout<<address<<endl;
// 17
const int num = 10;
std::vector s1(num);
std::array<string,num> s2;
// getchar();
// getchar();
return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值