UCLA A4


  • 作业标题:Homework 4 – due February 16th
  • 课程名称:University of California, Los Angeles (Winter 2022)
  • 完成周期:2天

Overview

Instructions: A template to answer this homework is provided on Bruinlearn. If you have
not set up a project with more than one .cpp file before, go back to the videos that I posted in
week 1. They explain how to get started. Your submission should consist only of functions.hpp
and functions.cpp. functions.hpp should contain function declarations with function comments.
functions.cpp should contain function definitions. While you are free to change the names of
function parameters, YOU CANNOT CHANGE FUNCTION NAMES OR PARAMETER TYPES.
Otherwise, youll likely get a build error and 0 points. We will test your functions by running
something similar to the main.cpp I provided.

  1. (6 points)
    (a) Write a pure function bool leap year(int year) that tests whether a year is a leap year.
    (Just like I did in class, you can assume the Gregorian correction has always applied.)
    Recall the description on wikipedia:
    \Every year that is exactly divisible by four is a leap year, except for years that are exactly
    divisible by 100, but these centurial years are leap years if they are exactly divisible by
  2. For example, the years 1700, 1800, and 1900 are not leap years, but the years 1600
    and 2000 are.”
    If you have a good understanding of booleans, your definition can be one line long.

。。。


文章作者: IT神助攻
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 IT神助攻 !
  目录