#2753: 윤년

#2753: 윤년

Java 16
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();

        if(input % 4 == 0 && input % 100 != 0 || input % 400 == 0) {
            System.out.println(1);
        }
        else System.out.println(0);
    }
}

실버는 아직 어려워여… 브론즈 좀만 더 할래여…

C
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    printf("%d", n % 4 == 0 && n % 100 != 0 || n % 400 == 0);
    return 0;
}
C++
#include <iostream>

auto main() -> int {
    int n; 
    std::cin >> n;
    std::cout << (n % 4 == 0 && n % 100 != 0 || n % 400 == 0);
    return 0;
}
C#
using System;

int n = int.Parse(Console.ReadLine());
Console.Write(n % 4 == 0 && n % 100 != 0 || n % 400 == 0 ? 1 : 0);
Python
n = int(input())
print(1 if n % 4 == 0 and n % 100 != 0 or n % 400 == 0 else 0)
Java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int n = new Scanner(System.in).nextInt();
        System.out.println(n % 4 == 0 && n % 100 != 0 || n % 400 == 0 ? 1 : 0);
    }
}
Kotlin
fun main() {
    val n = readLine()!!.toInt()
    println(if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) 1 else 0)
}
Pascal
var
    n: integer;
begin
    read(n);
    if (n mod 4 = 0) and (n mod 100 <> 0) or (n mod 400 = 0) then
        write(1)
    else 
        write(0);
end.
Haskell
main :: IO ()
main = getLine >>= print . fromEnum . f . read where
    f x = (x `mod` 4) == 0 && (x `mod` 100) /= 0 || (x `mod` 400) == 0
Rust
fn main() {
    let n = {
        let mut s = String::new();
    	std::io::stdin().read_line(&mut s).unwrap();
        s.trim().parse::<i32>().unwrap()
    };
    println!("{}", if n % 4 == 0 && n % 100 != 0 || n % 400 == 0 { 1 } else { 0 });
}
Ruby
n = gets.to_i
puts (n % 4 == 0 and n % 100 != 0 or n % 400 == 0) ? 1 : 0
1 Like