Write a program that calculates the number of days between the start time and the end time entered b

Updated on technology 2024-05-26
6 answers
  1. Anonymous users2024-02-11

    1 all"Please enter the start year");

    int x=;

    Please enter the year of termination");

    int y=;

    int z=(y-x)*365;

    Leap years in ordinary years are not considered, and it is unified here for 365 days, and if you want to achieve it, you will make changes ......

  2. Anonymous users2024-02-10

    datetime dt1 = start time.

    datetime dt2 = end time.

    timespan ts = dt1 - dt2;

    int sub = ;sub is the number of days between two days.

  3. Anonymous users2024-02-09

    Passed in VS2005.

    #include

    Determine whether it is a run-year*

    int leapyear(int iyear)

    return iyear%4 ? true : false;

    Get the number of days in the month*

    int leapmonth(int imonth,bool year)

    if(imonth == 2)

    if(year)

    return 29;

    else return 28;

    else if(imonth < 8&&imonth != 2)

    if(imonth%2)

    return 31;

    else return 30;

    else if(imonth%2)

    return 30;

    else return 31;

    void main()

    int preyear,premonth,preday;

    int sufyear,surmonth,sufday;

    Enter the start and end times*

    printf("start year:");

    printf("end year:");

    int idaysofyear = 0;

    int idaysofmonth = 0;

    for(int i = preyear; i < sufyear; i++)

    idaysofyear += leapyear(i)?366:365;

    int idaysofstartyear = 0;

    int idaysofendyear = 0;

    for(int a = 1; a < premonth; a++)

    idaysofstartyear += leapmonth(a,leapyear(preyear));

    idaysofstartyear += preday;

    for(int b = 1; b < surmonth; b++)

    idaysofendyear += leapmonth(b,leapyear(sufyear));

    idaysofendyear += sufday;

    int totalofdays = idaysofyear + idaysofendyear - idaysofstartyear;

    output *printf("total of days: %d",idaysofstartyear);

  4. Anonymous users2024-02-08

    *The program is used to calculate the number of days separated by two days in the same year (common year) * include

    using namespace std;

    int main()

    int mon1,day1,mon2,day2;

    cout<<"Please enter the start date (month, day)."<>mon1>>day1;

    cout<<"Enter the end date (month, day)."<>mon2>>day2;

    int a(0),b,c;

    int mon[12]=;

    for(;mon1b=a+day2-day1;

    cout<<"The number of days apart is :"

  5. Anonymous users2024-02-07

    Local variables mask global variables with the same name So:

    Call fun first to output the value of local variable a in the function 5, and then output the value of local variable b in the main function 5

    Exit the fun function The local variable a in the fun function ends at the end of the life period and then prinft prints the value of a is the value of the global variable a, and b is also the local variable of the main function, so the output is 5,5,0,5

  6. Anonymous users2024-02-06

    Use an array of 2 rows and 12 columns, record the number of days in each month in a leap year or not, and then the rest is simple.

Related questions
3 answers2024-05-26

Did you enter the format correctly? For example, enter a=1 and b=2! The format should be: >>>More

7 answers2024-05-26

Place a button and 2 textboxes in the form, enter information in text1 during runtime, and see the output result in text2 after clicking the button. >>>More

9 answers2024-05-26

Programs written by VB can be run on computers that do not have VB installed. >>>More

12 answers2024-05-26

Assign three numeric variables to three text boxes.

Write in an instance of a clip on one of the Stage: >>>More