<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>
            試題

            計算機二級C++上機綜合應用題

            時間:2025-02-25 02:34:55 試題 我要投稿
            • 相關推薦

            計算機二級C++上機綜合應用題

              為了使廣大考生在備戰計算機等級考試時,更快的掌握相應知識點,下面是小編搜索整理的計算機二級C++上機綜合應用題,供參考練習,預祝考生們考出自己理想的成績!

              綜合應用題

              使用VC++6.0打開考生文件夾下的源程序文件3.cpp,其中定義了用于表示日期的類Date,但類Date的定義并不完整,按要求完成下列操作,將類的定義補充完整。

              (1)定義私有成員變量year、month、day,分別表示年、月、日,類型為int。請在注釋1后添加適當的語句。

              (2)完成構造函數,分別給year、month、day賦值,請在注釋2后添加適當的語句。

              (3)完成重載符號“+=”的定義,請在注釋3后添加適當的語句。

              (4)完成函數print打印函數,如2005年1月5日到屏幕和文件out3.txt格式相同,請在注釋4后添加適當的語句。

              注意:增加代碼,或者修改代碼的位置已經用符號表示出來。請不要修改其他的程序代碼。

              試題程序:

              #include

              #include

              #include

              #include

              usingnamespacestd;

              voidWriteFile(intc)

              {

              ofstreamout1;

              out1.open("out3.txt",ios_base::app);out1<<c<<’’;

              out1.close();

              }

              voidWriteFile(char*str)

              {

              ofstreamout1;

              out1.open("out3.txt",ios_base::app);out1<<str;

              out1.close();

              }

              voidClearFile()

              {

              ofstreamout1;

              out1.open("out3.txt"):

              outl.close();

              }

              classDate

              {

              public:

              Date(inty,intm,intd)

              {

              //********1*********}

              voidprint();

              //********2********

              {

              month+=m:

              inti=month/12;

              intj=month%12;

              if(j==0)

              {

              year+=(i-1):

              month=12;

              }

              else

              {

              year+=i:

              month=j;

              }

              return*this:

              }

              private:

              //********3********

              };

              voidDate::print()

              {

              //********4********

              WriteFile(year);

              WriteFile("年");

              WriteFile(month);

              WriteFile("月");

              WriteFile(day);

              WriteFile("日");

              }

              intmain()

              {

              ClearFile();

              DateNationa1_day(2004,10,5);

              National_day+=3;

              National_day.print();

              return0;

              }

              答案:

              (1)應添加“year=y;month=m;day=d;”。

              (2)應添加“Date&operator+=(intm)”。

              (3)應添加“intyear,month,day;”。

              (4)應添加“cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;”。

              【解析】本題要求私有成員變量year、month、day為整形表示方法,所以注釋3應添加“intyear,month,day;”;注釋1要求分別給year、month、day賦值,根據上下文提意,所以應添加“year=y;month=m;day=d;”;注釋2是對“+=”運算符的重栽,Date&operator4+=(intm);第4處打印輸出年、月、日,C++語言中,輸出使用cout。

            【計算機二級C++上機綜合應用題】相關文章:

            2017計算機二級C++綜合應用題訓練08-30

            計算機二級C上機考試綜合應用題05-31

            計算機二級《C++》上機試題及答案08-12

            2016計算機二級《C++》上機沖刺題09-05

            2016計算機二級C++上機試題及答案08-02

            全國計算機二級《C++》上機試題及答案08-15

            計算機二級C++上機考試試題06-16

            2016計算機二級C++上機模擬試題及答案07-16

            2016計算機二級《C++》上機練習題06-09

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看