/***************************************
*                                      *
*       主に使用する変数等の設定       *
*                                      *
*                                      *
****************************************/

// 全体的な定義
#define SUM 0

// 年度に関する事項
#define SHONENDO             2010
#define SAISHUNENDO          2110
#define ECON_SHONENDO        2001
#define SOTOWAKU_SHONENDO    2005
#define SHIKKENRITU_MIN	     2000
#define SHIKKENRITU_MAX	     2060
#define LIFETABLE_NENDO	     2010
#define NENDO_JISSEKI        2012
#define N_O_NENDO            1926
#define R_KEINEN_SHONENDO    2010
#define R_KEINEN_SAISHUNENDO 2030
#define I_KEINEN_SHONENDO    2010
#define I_KEINEN_SAISHUNENDO 2060
#define CO_SHONENDO (SHONENDO - MAX_ROREI_JUKYU)
#define CO_SAISHUNENDO (SAISHUNENDO - 0)

// 被保険者に関する事項
	#define MAX_SHUBETU 7
		
	#define MAX_HIHO_NENREI 70
	#define MIN_HIHO_NENREI 20
	
	#define MAX_HIHO_KIKAN MAX_HIHO_NENREI - MIN_HIHO_NENREI
	#define HIHO_NENREI_SUM MAX_HIHO_NENREI + 1 - MIN_HIHO_NENREI
	
	#define NOUFU_JOKYO 4
	#define MENJO_JOKYO 7
	
// 受給者に関する事項
	#define MIN_ROREI_JUKYU   60
	#define MAX_ROREI_JUKYU  115
	#define KURI_AGE_SAGE_SHIKYU_KUBUN 70 - 60 + 1
	
	#define MIN_SHOGAI_JUKYU  20
	#define MAX_SHOGAI_JUKYU 115
	
	#define MIN_IZOKU_TUMA_JUKYU  16
	#define MAX_IZOKU_TUMA_JUKYU 115
	
	#define MIN_IZOKU_OTTO_JUKYU  18
	#define MAX_IZOKU_OTTO_JUKYU 115
	
	#define MIN_IZOKU_KO_JUKYU  0
	#define MAX_IZOKU_KO_JUKYU 19
	
	#define MIN_KAFU_JUKYU 26
	#define MAX_KAFU_JUKYU 64
	
	#define UNDER_67   67
	#define NENREI_SUM 62
	#define UNDER_64   64
	#define UNDER_63   63
	
	// 被保険者種別関係
	#define SHUBETU_SUM           0
	#define SHUBETU_OTOKO         7
	#define SHUBETU_ONNA          8
	#define SHUBETU_SUM_NENDOKAN  9
	
	// 受給開始年齢関係
	#define KURI_AGE_SAGE_SUM KURI_AGE_SAGE_SHIKYU_KUBUN
	
// 制度に関する事項
	#define MAX_MENJO 5
	
	#define NOUFU     1
	#define ZENGAKU   1
	#define MENJO_3_4 2
	#define MENJO_1_2 3
	#define MENJO_1_4 4
	#define GAKUSEI   5
	#define WAKAMONO  6
	
	// 国庫負担割合引き上げ
	#define KOKKO_HIKIAGE 3
	
	// 障害年金等級
	#define SHOGAI_TOKYU 3
	
// テクニカルな定義
#define BUFFER_MAX 110
#define DATA_MAX 120


// 関数の設定
// main 関数
void file_open();
void cntl();
void seid();
void econ();
void zero();
void waku();
void kiso( int shubetu );
void dtst( int shubetu );
void noufuritu( int shubetu );
void siml( int nendo , int shubetu );
void shke( int nendo , int shubetu );
void stat();
void printout();
void kaizen();
int PerformSiml( int shubetu );

// 標準フォーマット関数
int read_data( double buffer[] , FILE *fp , int *data_number_ptr );
void read_headder( FILE *fp );
void readkiso_error( int shurui );
void write_BeginData( char Version[] , char ShisanNaiyou[] , FILE *fp );
void VersionConfirm( );
double max( double a , double b );
double min( double a , double b );

// オプションⅢ用
int encho_year( int a );

// 構造体演算関数
struct hihokensha scalar( double scalar , struct hihokensha InputStruct );
struct rorei scalar( double scalar , struct rorei InputStruct );
struct rorei_kyu scalar( double scalar , struct rorei_kyu InputStruct );
struct gonen scalar( double scalar , struct gonen InputStruct );
struct shogai scalar( double scalar , struct shogai InputStruct );
struct izoku scalar( double scalar , struct izoku InputStruct );
struct kafu scalar( double scalar , struct kafu InputStruct );

struct hihokensha scalar_2( double scalar , struct hihokensha InputStruct , int nendo );

struct hihokensha add( struct hihokensha InputStruct1 , struct hihokensha InputStruct2 );
struct rorei add( struct rorei InputStruct1 , struct rorei InputStruct2 );
struct rorei_kyu add( struct rorei_kyu InputStruct1 , struct rorei_kyu InputStruct2 );
struct gonen add( struct gonen InputStruct1 , struct gonen InputStruct2 );
struct shogai add( struct shogai InputStruct1 , struct shogai InputStruct2 );
struct izoku add( struct izoku InputStruct1 , struct izoku InputStruct2 );
struct kafu add( struct kafu InputStruct1 , struct kafu InputStruct2 );
struct ichijikin add( struct ichijikin InputStruct1 , struct ichijikin InputStruct2 );

struct hihokensha average_by_ninzu( struct hihokensha InputStruct );

struct rorei multiply( struct rorei InputStruct1 , struct rorei InputStruct2 );
struct rorei_kyu multiply( struct rorei_kyu InputStruct1 , struct rorei_kyu InputStruct2 );
struct shogai multiply( struct shogai InputStruct1 , struct shogai InputStruct2 );
struct izoku multiply( struct izoku InputStruct1 , struct izoku InputStruct2 );
struct kafu multiply( struct kafu InputStruct1 , struct kafu InputStruct2 );

struct rorei adjustbenefit( double scalar , struct rorei InputStruct );
struct rorei_kyu adjustbenefit( double scalar , struct rorei_kyu InputStruct );
struct gonen adjustbenefit( double scalar , struct gonen InputStruct );
struct shogai adjustbenefit( double scalar , struct shogai InputStruct );
struct izoku adjustbenefit( double scalar , struct izoku InputStruct );
struct kafu adjustbenefit( double scalar , struct kafu InputStruct );

struct rorei nendokan( struct rorei InputStruct1 , struct rorei InputStruct2 , double kaiteiritu );
struct rorei_kyu nendokan( struct rorei_kyu InputStruct1 , struct rorei_kyu InputStruct2 , double kaiteiritu );
struct gonen nendokan( struct gonen InputStruct1 , struct gonen InputStruct2 , double kaiteiritu );
struct shogai nendokan( struct shogai InputStruct1 , struct shogai InputStruct2 , double kaiteiritu1 , double kaiteiritu2 );
struct izoku nendokan( struct izoku InputStruct1 , struct izoku InputStruct2 , double kaiteiritu1 , double kaiteiritu2 );
struct kafu nendokan( struct kafu InputStruct1 , struct kafu InputStruct2 , double kaiteiritu );
struct ichijikin nendokan( struct ichijikin InputStruct1 , struct ichijikin InputStruct2 , double kaiteiritu );

struct rorei nendokan_64( struct rorei InputStruct1 , struct rorei InputStruct2 , struct rorei InputStruct3 , double kaiteiritu );
struct rorei_kyu nendokan_64( struct rorei_kyu InputStruct1 , struct rorei_kyu InputStruct2 , struct rorei_kyu InputStruct3 , double kaiteiritu );
struct gonen nendokan_64( struct gonen InputStruct1 , struct gonen InputStruct2 , struct gonen InputStruct3 , double kaiteiritu );
struct shogai nendokan_64( struct shogai InputStruct1 , struct shogai InputStruct2 , struct shogai InputStruct3 , double kaiteiritu );
struct izoku nendokan_64( struct izoku InputStruct1 , struct izoku InputStruct2 , struct izoku InputStruct3 , double kaiteiritu );
struct ichijikin nendokan_64( struct ichijikin InputStruct1 , struct ichijikin InputStruct2 , struct ichijikin InputStruct3 , double kaiteiritu );
