网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

请问,如下程序是否可以编译成功() class CDate { const int year=2000; public: CDate(int year):year(year){…} CDate(int year=2000):year(year){…} };

A.可以

B.不可以,因为year不能为const

C.不可以,因为两个构造函数无法区分

D.不可以,因为year是const,不能在构造函数中设置值


参考答案和解析
B
更多 “请问,如下程序是否可以编译成功() class CDate { const int year=2000; public: CDate(int year):year(year){…} CDate(int year=2000):year(year){…} };A.可以B.不可以,因为year不能为constC.不可以,因为两个构造函数无法区分D.不可以,因为year是const,不能在构造函数中设置值” 相关考题
考题 ( 38 )有以下定义和语句struct workers{ int num;char name[20];char c;struct{ int day; int month; int year; } s;} ;struct workers w,*pw;pw = w;能给 w 中 year 成员赋 1980 的语句是A ) *pw.year = 198O;B ) w.year=1980;C ) pw-year=1980;D ) w.s.year=1980;

考题 请在每条横线处填写一个语句,使程序的功能为:判断输入的年份是否为闰年(例如:1998年不是闰年,2000年是闰年).注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。import java.io.*;public class LeapYear{public static void main(String args[]){___________________;BufferedReader in;ir=new InputStreamReader(_____________________________);in=new BufferedReader(ir);System. out. print In("输入年份是: ");String s=in.readline();int year=___________________if(year%4==0year%100!=0||year%400==0System.out.println(" "+year+" "年是闰年. ");elseSystem.out.println(" " +year+ " "年不是闰年.");}}}

考题 有以下程序: Class Date { public: Date(int y,int m,mt d); { year=y; month=m; day=d; } Date(int y=2000) { year=y; month=10; day=1; } Date(Date D) { year=d.year; month=d.month; day=d.day; } Void prinA.2B.3C.4D.5

考题 在下面程序的横线处填上______,使程序执行后的输出结果为1/2005。 include using nam 在下面程序的横线处填上______,使程序执行后的输出结果为1/2005。include<iostream.h>using namespace std;class Date{Public:Date(int m=1,int y=0): month(m),year(y){}void Print(){cout<<month<<"/"<<year<<end1;}______operator+(const Dated1,const Dated2);private:int month, year;};Date operator+(const Dated1,const Dated2){int year,month;year=d1.year+d2.year;month=d1.month+d2.month;year+=(month-1)/12;month=(month-1)%12+1;return Date(month,year);}void main(){Date d1(3,2004),d2,d3(10);d2=d3+d1;d2.Print();}

考题 已知学生记录描述为 struct student { int no; char name[20]; char sex; struct { int year; int month; int day; } birth; }; struct student s;变量s中的“生日”应是“1985年4月4日”,下列对“生日”的正确赋值方式是______。A.year=1985;month=4;day=4;B.birth.year=1985;birth.month=4;birth.day=4;C.s.year=1985;s.month=4;s.day=4;D.s.birth.year=1985;s.birth.month=4;s.birth,day=4;

考题 有以下程序:class Date{public:Date(int y,int m,int d);{year=y;month=mday=d;}Date(int y=2000){year=y;month=10;day=1;}Date(Date d){year=d.year;month=d.month;day=d.day;}void print( ){cout<<year<<"."<<month<<"."<<day<<endl;}private:int year,month,day;};Date fun(Date d){Date temp;temp=d;return temp;}int main( ){Date datel(2000,1,1),date2(0,0,0);Date date3(datel);date2=fun(date3);return 0;}程序执行时,Date类的拷贝构造函数被调用的次数是A.2B.3C.4D.5

考题 请补充fun函数,该函数的功能是:判断一个年份是否为闰年。例如,1900年不是闰年,2004是闰年。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。[试题源程序]include<stdio.h>include<conio.h>int fun(int n){int fiag=0;if(n%4==0){if( (1) )fiag=1;}if( (2) )flag=1;return (3) ;}void main(){int year;clrscr();printf("Input the year:");scanf("%d", &year);if(fun(year))printf("%d is a leap year.\n", year);elseprintf("%d is not a leap year.\n", year);}

考题 从下列的3道式题(试题五至试题七)中任选1道解答。如果解答的试题数超过1道,则题号小的1道解答有效。阅读以下说明和C++码,将应填入(n)处的字名写在的对应栏内。[说明] 利用c++的各种控制语句编写一个万年历程序,要求:显示任何年份的日历,日历以月份顺序排列,每月以星期顺序排列,类似于一般挂历上的格式。本程序包含如下两个函数:Leap ()用于判定指定的年份是闰年,Week ()用于计算year年份的1月1日是星期几,其判定规则为:(1) 如果year 年份为1994年,则为星期六。(2) 如果year 年份大于1994年,则星期值weekno 按下列公式计算:differ=(year-1994)*(365%6)+(year-1993)/4-(year-2001)/100+(year-2001)/400 date=6+differ%7weekno=(date6)? date-7:date(3) 如果year 年份小于1994年,则星期值weekno 按下列公式计算:differ=(1994-year)*(365%7)+(1996-year)/4-(2001-year)/100+(2000-year)/400 weekno=6-dder%7include "iostream. h"include "iomanip. h"int leap(int n){if( (1) )return 0elsereturn 1;}int week( int year ){int a1, differ, date, weekno;if (year = = 1994)a1 =0;else if (year > 1994)a1=1;else a1= -1;switch(a1){case 0: return 6; break;case 1:{(2)date = 6 + differ% 7; weekno = ( date > 6) ? date - 7 date;}return weekno; break;case - 1:{differ = ( 1994 - year) * (365%7) + (1996 - year)/4 - (2001 - year)/100 + (2000 - year)/400;weekno =6-differ%7; } return weekno; break;}}void main( )}int i,year,m2,n,j;cout < < “Please input 某年数:”;cin> >year;if ( ! leap(year) )(3);elsem2 =28;int month [12]: {31 ,m2,31,30,31,30,31,31,30,31,30,31 };(4)for ( i=0; i<12; i+ + ){cout< < < <end1< <setw(4*n) < <";for(j=1 ;j< =month [i] ;j+ +){cout< <setw(4) < <j;n+ +;if(n> =7){(5)cout < < end1;}}}}

考题 下面程序是判断某一个是否为闰年,请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。(闰年的条件是符合下面两者之一:①能被4整除,但不能被100整除;②能被4整除,又能被100整除)。注意:不改动程序的结构,不得增行或删行。import java.io.*;public class LeapYear{public static void main(String args[]){int year=1979;if((year %4= =0 || year % 100 !=0) || (year % 400= =0))System.out.println(year+"是闰年.");elseSystem.out.println(year+"不是闰年。");year=2000;boolean leap;if(year % 4 !=0)leap=false;else if(year % 100 !=0)leap=true;else if(year % 400 !=0)leap=false;elseleap=true;if(______)System.out.println(year+"是闰年。");elseSystem.out.println(year+"不是闰年。");year=2010;if(year % 4= =0){if(year % 100= =0){if(year % 400= =0)leap=true;else______}elseleap=false;}if(1eap= =true);System.out.println(year+"是闰年。");elseSystem.out.println(year+"不是闰年。");}}

考题 有以下程序: class Date { public: Date(int y,int m,int D) ; { year =y; month=m; day=d; } Date(int y=2000) { year=y; month=10; day=1; } Date(Date D) { year=d.year; month=d.month; day=d.day; } void print () { cout<<year<<"."<<month<<"."<<day<<end1; } private: int year,month,day; }; Date fun(Date D) { Date temp; temp=d; return temp; } int main() { Date date1(2000,1,1),date2(0,0,0); Date date3(date1); date2=fun(date3); return 0; } 程序执行时,Date类的拷贝构造函数被调用的次数是A.2B.3C.4D.5

考题 下面结构体的定义语句中,不正确的是______。A.structdate { int month; int day; int year; } Struct date datel;B.stmctdate { intmonth; int day; int year; } datel;C.struct { int month; int day; int year; } date 1;D.#define DATE stmct date DATE { int month; int day; int year; }datel;

考题 有以下程序include using namespace std;static int days[]= { 31,28,31,30,31,30,31 有以下程序 #include <iostream> using namespace std; static int days[]= { 31,28,31,30,31,30,31,31,30,31,30,31 }; class date { private: int month, day, year; public: date( int m, int d, int y ) { month = m; day = d; year = y; } date() {} void disp() { cout<<year<<"-"<<month<<"-"<<day<<end1; } date operator+( int day ) { date dt = *this; day+= dt.day; while ( day > days[dt.month - 1 ] ) { day -= days[ dt.month - 1 ]; if ( ++dt.month == 13 ) { dt.month = 1; dt.year++; } } dt.day = day; return dt; }; int main() { date d1( 6, 20, 2004 ), d2; d2: d1 + 20; d2.disp(); return 0; } 执行后的输出结果是A.2004-7-10B.2004-6-20C.2004-7-20D.程序编译时出错

考题 针对下列程序段,需要(58)个测试用例可以满足分支覆盖的要求。 int IsLeap(int year) { if(year % 4==0) { if((year % 100==0) { if(year % 400==0) leap=1; else leap=0; } else leap=l; } else leap=0; return leap; }A.3B.4C.6D.7

考题 阅读以下说明和C++抖程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】下面程序的功能是计算并输出某年某月的天数。【C++程序】include<iostream>using namespace std;(1) Month{Jan,Feb,Mar,Art,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec};class Date{public:Date(int year,Month m_month){(2) =year;if (m_month<Jan‖m_month>Dec) month=Jan;else month=m_month;};~Date(){};bool IsLeapYear(){return ((year%4==0 year%1001!=0)‖year%400==0);};int CaculateDays(){switch( (3) ){case Feb:{if( (4) )return29;e1Se return 28;}case Jan:case Mar:case May:case Jul:case AUg:case Oct:case Dec:retllrn 31;case Apr:case Jun:Case Sep:case Nov:roturu30;}};private:int year;Month month;};void main(){Date day(2000,Feb);tout<<day. (5) ();}

考题 在下面程序的横线处填上适当的内容,使程序执行后的输出结果为1/2005。includeusing n 在下面程序的横线处填上适当的内容,使程序执行后的输出结果为1/2005。include <iostream.h>using namespace std:class Datepublic:Date (int m=1,int y=0):month(m .year(y}{}void Print() {cout<<month<<"/"<<year<<end1;}______operator+(const Date d1,const Dated2;private:int month year;};______operaror+(const Dated1,const Date d2)int year, month;year=d1.year+d2.year;month=d1.month+d2.month;year+=(month-1)/12;month=(month-1)%12+l;return Date{month, year}:}void main(){Date d1(3,2004),d2,d3(10);d2=d3+d1;d2.Print();}

考题 已知:Manager extends Employee观察:public Manager(String n,double s,int year,int month,int day) { super(n,s,year,month,day); bonus=0; }其中super是 ( )A.Object类B.Manager类C.Employee类D.Class类

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】下面程序的功能是计算并输出某年某月的天数,函数IsLeap Year()能够判断是否是闰年。【C++程序】include < iostream >using namespace std;(1) Month {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };class Date {public:Date( int year, Month m_ month) {this→year = year;if( (2) ) month: Jan;else month = m_ month;};~Date(){};bool IsLeap Year( ) {return ((year%4= =0 year% 100 ! =0)|| year%400= =0);};int CaculateDays( ) {switch(m_month ) {case (3) ;{if (4) return 29;else return 28;}case Jan: case Mar: case May: case Jul: case Aug: case Oct: case Dec: return 31;case Apr: case Jun: case Sop: case Nov: return 30;}}private:int year;Month month;};void main( ) {Date day(2000,Feb);cout < <day. (5) ( );}

考题 在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。 include using 在下向程序和横线处填上适当的内容,使程序执行后的输出结果为1/2005。include <iostream>using namespace std;class Date{public:Date(int m=1,int y=0):month(m),year(y){}void Print() {cout<<month<<"/"<<year<<end 1; }【 】 operator+(eonst Date d1, const Date d2);private:int month,year;};【 】 operator+(const Date d1, const Date d2){int year,month;year=d1.year+d2.year;month=d1. month+d2.month;year+=(month-1 )/12;month=(month-1 )% 12+1;return Date(month,year);}void main()Date d1 (3,2004),d2,d3(10);d2=d3+d1;d2,Print();}

考题 以下代码用于判断闰年,由C 语言书写。其对应的控制流图如下图所示。 请按要求回答问题。 int isLeap(int year){ int leap; if (year % 4 = = 0){ if (year % 100 = = 0){ if ( year % 400 = = 0) leap = 1; else leap = 0; } else leap = 1; } else leap = 0; return leap; } (1)请画出控制流图,并计算圈复杂度V(G)。 (2)找出独立路径。

考题 有以下程序: Class Date {public: Date(int y,int m,int d); {year=y; month=m; day=d;} Date(int y=2000) {year=y; month=10; day=1;) Date(Date D) {year=d.year; month=d.month; day=d.day;} void print() {cout<<year<<“.”<<moA.2B.3C.4D.5

考题 某C语言结构体的定义如下。 struct date { int year, month, day; }; struct worklist { char name[20]; char sex; struct date birthday; }person; 若对变量person的出生年份进行赋值,正确的赋值语句是(33)。A.year=1976B.birthday. year=1976C.person. year=1976D.person. birthday. year=1976

考题 ● 针对下列程序段,需要(58)个测试用例可以满足分支覆盖的要求。int IsLeap(int year){if ( year % 4 == 0 ){if ( ( year % 100 == 0 ){if ( year % 400 == 0 )leap = 1;elseleap = 0;}elseleap = 1;}elseleap = 0;return leap;}(58)A.3B.4C.6D.7

考题 有下列语句:  struct Birthday{public int year;  public int month;   public int day;}; struct Student{ int no;  string name;   int age;  public Birthday bir; };  ……  Student Stu;  如果要把Stu的出生年份赋值为1988,正确的语句是()A、 Stu.bir.year=1988;B、 Stu.year=1988;C、 Stu. Birthday.year=1988;D、 Student. Birthday.year=1988;

考题 程序:   class MyDate{   private int year;   private int month;   private int day;   public MyDate( int year, int month,int day){   this.year=year;   this.month=month;   this.day=day;  }   //Override Method  }   为了让new MyDate(1980,11,9)==(判断是否相等)new MyDate(1980,11,9) 返 回true,必须在Override Method处覆盖哪个方法?()A、 hashCodeB、 equalsC、 toStringD、 notify

考题 程序:  class MyDate{   private int year; private int month; private int day;  public MyDate(int year,int month,int day){  this.year=year;  this.month=month;      this.day=day; }  //Override Method }  为了让new MyDate(1980,11,9)==new MyDate(1980,11,9) 返回true,必须在Override Method处覆盖哪个方法?() A、 hashCodeB、 equalsC、 toStringD、 notify

考题 单选题程序:   class MyDate{   private int year;   private int month;   private int day;   public MyDate( int year, int month,int day){   this.year=year;   this.month=month;   this.day=day;  }   //Override Method  }   为了让new MyDate(1980,11,9)==(判断是否相等)new MyDate(1980,11,9) 返 回true,必须在Override Method处覆盖哪个方法?()A  hashCodeB  equalsC  toStringD  notify

考题 单选题程序:  class MyDate{   private int year; private int month; private int day;  public MyDate(int year,int month,int day){  this.year=year;  this.month=month;      this.day=day; }  //Override Method }  为了让new MyDate(1980,11,9)==new MyDate(1980,11,9) 返回true,必须在Override Method处覆盖哪个方法?()A  hashCodeB  equalsC  toStringD  notify

考题 多选题在VisualFoxpro中,运算结果是日期型数据的表达式有()。ADATE()+YEAR(DATE())B{^01/01/03}+YEAR(DATE())CDATE()-(12/06/99)DDATE()+20