printf("ho_tari\n");

ordinaryLeap 본문

C

ordinaryLeap

호타리 2023. 9. 1. 11:49
#include <stdio.h>



int main(void)

{

	int year;

	scanf("%d", &year);

	

	//int isLeap = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);

	//int isLeap = (year % 400 == 0 || year % 4 == 0 && year % 100 != 0);

	//printf("%d is leap : %d\n", year, isLeap);

	

	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)

	{

		printf("%d is a leap year\n", year);

	}

	else

	{

		printf("%d is an ordinary year\n", year);

	}

	

	return 0;

}

 

#include <stdio.h>



int main(void)

{

	int year;

	scanf("%d", &year);

	

	//int isLeap = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);

	//int isLeap = (year % 400 == 0 || year % 4 == 0 && year % 100 != 0);

	//printf("%d is leap : %d\n", year, isLeap);

	

//	if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)

//	{

//		printf("%d is a leap year\n", year);

//	}

//	else

//	{

//		printf("%d is an ordinary year\n", year);

//	}



	printf("%d is %s year\n", year, 

		(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? "a leap" : "an ordinary");

	

	return 0;

}

 

<compile 결과>

'C' 카테고리의 다른 글

pointer  (0) 2023.09.01
passFail  (0) 2023.09.01
one2Ten  (0) 2023.09.01
oddEven  (0) 2023.09.01
myProfile  (0) 2023.09.01