首页 > 其他分享 >4.23

4.23

时间:2023-04-23 20:45:21浏览次数:28  
标签:cout int void stl1 student input 4.23

include <iostream>

using namespace std;

#include"time_user.h"

class student

{

public:

    void display();

public:

    int num;

    string name;

    char sex;

 

};

void student::display()

{

    cout << "num: " << num << endl;

    cout << "name: " << name << endl;

    cout << "sex: " << sex << endl;

}

int main()

{

    student stl1;

    stl1.name = "gyg";

    stl1.num = 1001;

    stl1.sex = 'm';

    stl1.display();

 

}

实验二

#include <iostream>

using namespace std;

#include"time_user.h"

class student

{

private:

    int age;

    string name;

public:

    void input(int a, string str)

    {

        age = a;

        name = str;

    }

    void output()

    {

        cout << "name: " << name << endl;

        cout << "age: " << age << endl;

    }

};

int main()

{

    student s[3];

    s[0].input(18, "gyg");

    s[1].input(19, "guo");

    s[2].input(20, "zy");

    for (int i = 0; i < 3; i++)

    {

        s[i].output();

    }

标签:cout,int,void,stl1,student,input,4.23
From: https://www.cnblogs.com/lml66/p/17347671.html

相关文章

  • 编程一小时2023.4.23
    1.#include<bits/stdc++.h>usingnamespacestd;stringa,s;intb[1005],t,c[1005];voiddivision(){for(inti=t-1;i>=0;i--){if(b[i]%2)b[i-1]+=10;b[i]/=2;}while(b[t-1]==0)t-......
  • 4.23打卡
    一、问题描述: 爱因斯坦出了一道这样的数学题:有一条长阶梯,若每步跨2阶,则最后剩一阶,若每步跨3阶,则最后剩2阶,若每步跨5阶,则最后剩4阶,若每步跨6阶则最后剩5阶。只有每次跨7阶,最后才正好一阶不剩。请问在1~N内,有多少个数能满足?二、设计思路:该问题要求输入N值,求解出在1-N的范围内存在......