这是我的代码:
#ifndef PROBLEM3_H
#define PROBLEM3_H
#include <string>
struct stackItem {
// arbritary name do define item
string name;
};
class Hw3Stack {
public:
// Default constuctor that prompts the user for the stack
// capacity, initalizes the stack with the capacity, and the sets
// the size of zero.
Hw3Stack();
// Copy constructor that takes a current stack and copies the
// current size, capacity, and stackItems into the current object.
Hw3Stack(Hw3Stack& stack);
// Destructor that deletes the stack
~Hw3Stack(); …
Run Code Online (Sandbox Code Playgroud) 我必须要求用户输入开始日期和结束日期.日期必须是YYYY-MM-DD格式.我已经编写了一些if语句来处理用户可能会做出的一些格式错误,例如不在其间输入破折号,以及在彼此的位置输入月份和日期.
我现在需要的是确保结束日期始终晚于开始日期的方法.从逻辑上讲,结束日期不能在开始日期之前发生.
我不知道有办法做到这一点.任何帮助将不胜感激,谢谢.
def get_start_date() -> str:
START_DATE = input('Enter start date (in YYYY-MM-DD format): ').strip()
if len(START_DATE) != 10:
print('Date entry not correct, please try again')
get_start_date()
elif eval(START_DATE[5]) > 1:
print('Date entry not correct, please try again')
get_start_date()
elif eval(START_DATE[8]) > 3:
print('Date entry not correct, please try again')
get_start_date()
elif START_DATE[4] and START_DATE[7] != '-':
print('Date entry not correct, please try again')
get_start_date()
def get_end_date() -> str:
END_DATE = input('Enter end date (in YYYY-MM-DD format): ').strip()
if …
Run Code Online (Sandbox Code Playgroud)