YTU.2532: 投簡曆

來源:互聯網
上載者:User
2532: 投簡曆 Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 1126   Solved: 802
[ Submit][ Status][ Web Board] Description

小華曆經12寒窗苦讀,又經曆4年大學磨礪,終於畢業了,隨著畢業季的到來,找工作也日益緊張起來。由於要面試不同的公司,因此小華需要準備不同的簡曆。當然最基本的資訊是必不可少的,基本資料:姓名、年齡、性別、專業。現有兩家公司,小華想要投簡曆試一試。第一家langchao公司需要瞭解小華畢業學校,第二家lenovo公司需要瞭解小華的薪金目標(pay)。
請你用類中繼承的方法協助他完成簡曆吧*-*  *-*  *-* Input

輸入兩行,第一行:小華的資訊。第二行:小華想要進入的公司名稱。 Output

小華要遞交的簡曆內容 Sample Input

xiaohua 25 F IT YT 8000langchao
Sample Output
name:xiaohuaage:25sex:Fmajor:ITschool:YT
HINT

前置代碼及類型定義已給定如下,提交時不需要包含,會自動添加到程式前部

#include <iostream>

#include <string>

using namespace std;

class jianli

{

public:

    void getvalue(){

        cin>>name>>age>>sex>>major;

    }

    void display();

private:

    string name;

    int age;

    char sex;

    string major;

};

主函數已給定如下,提交時不需要包含,會自動添加到程式尾部







/* C++代碼 */

int main()

{

    jianli1 xiaohua;

    jianli2 xiaohua2;

    string a="langchao",b="lenovo";

    string c;

    xiaohua.getvalue();

    xiaohua.getvalue1();

    xiaohua2.getvalue2();

    cin>>c;

    if(c==a){

        xiaohua.display();

        xiaohua.display1();

    }

    if(c==b){

        xiaohua.display();

        xiaohua2.display2();

    }

    return 0;

}

分析:

jianli1類繼承jinali類,添加了新的成員school;
jianli2類繼承jinali類,添加了新的成員pay;

AC代碼:

class jianli1:public jianli  {  public:  void getvalue1()  {  cin>>school;  }  void display1();  private:  string school;  };   class jianli2:public jianli { public: void getvalue2() { cin>>pay; } void display2(); private: double pay;  } ;  void jianli::display()  {      cout<<"name:"<<name<<endl;      cout<<"age:"<<age<<endl;      cout<<"sex:"<<sex<<endl;      cout<<"major:"<<major<<endl;    }  void jianli2::display2()  {      cout<<"pay:"<<pay<<endl;  }    void jianli1::display1()  {      cout<<"school:"<<school<<endl;  }


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.