[ create a new paste ] login | about

Link: http://codepad.org/cCFTN48N    [ raw code | fork ]

C, pasted on Oct 25:
#include <stdio.h>

enum {
	KOLYMPIC,
	TOLYMPIC,
	NONE
};

int olympic(int);

int main()
{
	int year;
	int value;
	
	printf("西暦年を入力してください>>");
	scanf("%d",&year);
	
	value = olympic(year);
	
	switch (value)
	{
		case 0:
		printf("夏季オリンピック\n");
		break;
		
		case 1:
		printf("冬季オリンピック\n");
		break;
		
		case 2:
		printf("開催されません\n");
		break;
	}
}

int olympic(int year)
{
	if ( year % 4 == 0 )
	{
		return KOLYMPIC;
	}
	if ( year % 4 == 2 )
	{
		return TOLYMPIC;
	}
	else { return NONE; }
}


Create a new paste based on this one


Comments: