Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. void leapYear(int year) {
  2.     if (year % 4 == 0) {
  3.         if (year % 100 == 0) {
  4.             if (year % 400 == 0) {
  5.                 std::cout << year << " on karkausvuosi." << std::endl;
  6.                 std::cin.ignore();
  7.                 std::cin.get();
  8.  
  9.             }
  10.             else {
  11.                 std::cout << year << " ei ole karkausvuosi." << std::endl;
  12.                 std::cin.ignore();
  13.                 std::cin.get();
  14.             }
  15.         }
  16.         else {
  17.             std::cout << year << " ei ole karkausvuosi." << std::endl;
  18.             std::cin.ignore();
  19.             std::cin.get();
  20.         }
  21.     }
  22. }
  23.  
  24. int main(void){
  25.     int year = 0;
  26.  
  27.     std::cout << "Anna vuosiluku:" << std::endl;
  28.     while (!(std::cin >> year)) {
  29.         std::cin.clear();
  30.         std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  31.         std::cout << "Anna vuosiluku:" << std::endl;
  32.     }
  33.  
  34.     leapYear(year);
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement