农历阳历之间转换和节气节日查询C语言编程
//基于1602液晶显示的程序设计#include<reg52.h>//C51写的公历转农历和星期#define uchar unsigned char#define uint unsigned int/*公历年对应的农历数据,每年三字节,格式第一字节BIT7-4 位表示闰月月份,值为0 为无闰月,BIT3-0 对应农历第1-4 月的大小第二字节BIT7-0 对应农历第5-12 月大小,第三字节BIT7 表示农历第13 个月大小月份对应的位为1 表示本农历月大(30 天),为0 表示小(29 天)第三字节BIT6-5 表示春节的公历月份,BIT4-0 表示春节的公历日期*/code uchar year_code[597] = {0x04,0xAe,0x53, //19010x0A,0x57,0x48, //19020x55,0x26,0xBd, //19030x0d,0x26,0x50, //19040x0d,0x95,0x44, //19050x46,0xAA,0xB9, //19060x05,0x6A,0x4d, //19070x09,0xAd,0x42, //19080x24,0xAe,0xB6, //19090x04,0xAe,0x4A, //19100x6A,0x4d,0xBe, //19110x0A,0x4d,0x52, //19120x0d,0x25,0x46, //19130x5d,0x52,0xBA, //19140x0B,0x54,0x4e, //19150x0d,0x6A,0x43, //19160x29,0x6d,0x37, //19170x09,0x5B,0x4B, //19180x74,0x9B,0xC1, //19190x04,0x97,0x54, //19200x0A,0x4B,0x48, //19210x5B,0x25,0xBC, //19220x06,0xA5,0x50, //19230x06,0xd4,0x45, //19240x4A,0xdA,0xB8, //19250x02,0xB6,0x4d, //19260x09,0x57,0x42, //19270x24,0x97,0xB7, //19280x04,0x97,0x4A, //19290x66,0x4B,0x3e, //19300x0e,0xA5,0x46, //1932 0x56,0xd4,0xBA, //1933 0x05,0xAd,0x4e, //1934 0x02,0xB6,0x44, //1935 0x39,0x37,0x38, //1936 0x09,0x2e,0x4B, //1937 0x7C,0x96,0xBf, //1938 0x0C,0x95,0x53, //1939 0x0d,0x4A,0x48, //1940 0x6d,0xA5,0x3B, //1941 0x0B,0x55,0x4f, //1942 0x05,0x6A,0x45, //1943 0x4A,0xAd,0xB9, //1944 0x02,0x5d,0x4d, //1945 0x09,0x2d,0x42, //1946 0x2C,0x95,0xB6, //1947 0x0A,0x95,0x4A, //1948 0x7B,0x4A,0xBd, //1949 0x06,0xCA,0x51, //1950 0x0B,0x55,0x46, //1951 0x55,0x5A,0xBB, //1952 0x04,0xdA,0x4e, //1953 0x0A,0x5B,0x43, //1954 0x35,0x2B,0xB8, //1955 0x05,0x2B,0x4C, //1956 0x8A,0x95,0x3f, //1957 0x0e,0x95,0x52, //1958 0x06,0xAA,0x48, //1959 0x7A,0xd5,0x3C, //1960 0x0A,0xB5,0x4f, //1961 0x04,0xB6,0x45, //1962 0x4A,0x57,0x39, //1963 0x0A,0x57,0x4d, //1964 0x05,0x26,0x42, //1965 0x3e,0x93,0x35, //1966 0x0d,0x95,0x49, //1967 0x75,0xAA,0xBe, //1968 0x05,0x6A,0x51, //1969 0x09,0x6d,0x46, //1970 0x54,0xAe,0xBB, //1971 0x04,0xAd,0x4f, //1972 0x0A,0x4d,0x43, //1973 0x4d,0x26,0xB7, //19740x8d,0x52,0xBf, //19760x0B,0x54,0x52, //19770x0B,0x6A,0x47, //19780x69,0x6d,0x3C, //19790x09,0x5B,0x50, //19800x04,0x9B,0x45, //19810x4A,0x4B,0xB9, //19820x0A,0x4B,0x4d, //19830xAB,0x25,0xC2, //19840x06,0xA5,0x54, //19850x06,0xd4,0x49, //19860x6A,0xdA,0x3d, //19870x0A,0xB6,0x51, //19880x09,0x37,0x46, //19890x54,0x97,0xBB, //19900x04,0x97,0x4f, //19910x06,0x4B,0x44, //19920x36,0xA5,0x37, //19930x0e,0xA5,0x4A, //19940x86,0xB2,0xBf, //19950x05,0xAC,0x53, //19960x0A,0xB6,0x47, //19970x59,0x36,0xBC, //19980x09,0x2e,0x50, //1999 294 0x0C,0x96,0x45, //2000 297 0x4d,0x4A,0xB8, //20010x0d,0x4A,0x4C, //20020x0d,0xA5,0x41, //20030x25,0xAA,0xB6, //20040x05,0x6A,0x49, //20050x7A,0xAd,0xBd, //20060x02,0x5d,0x52, //20070x09,0x2d,0x47, //20080x5C,0x95,0xBA, //20090x0A,0x95,0x4e, //20100x0B,0x4A,0x43, //20110x4B,0x55,0x37, //20120x0A,0xd5,0x4A, //20130x95,0x5A,0xBf, //20140x04,0xBA,0x53, //20150x0A,0x5B,0x48, //20160x65,0x2B,0xBC, //20170x05,0x2B,0x50, //20180x47,0x4A,0xB9, //2020 0x06,0xAA,0x4C, //2021 0x0A,0xd5,0x41, //2022 0x24,0xdA,0xB6, //2023 0x04,0xB6,0x4A, //2024 0x69,0x57,0x3d, //2025 0x0A,0x4e,0x51, //2026 0x0d,0x26,0x46, //2027 0x5e,0x93,0x3A, //2028 0x0d,0x53,0x4d, //2029 0x05,0xAA,0x43, //2030 0x36,0xB5,0x37, //2031 0x09,0x6d,0x4B, //2032 0xB4,0xAe,0xBf, //2033 0x04,0xAd,0x53, //2034 0x0A,0x4d,0x48, //2035 0x6d,0x25,0xBC, //2036 0x0d,0x25,0x4f, //2037 0x0d,0x52,0x44, //2038 0x5d,0xAA,0x38, //2039 0x0B,0x5A,0x4C, //2040 0x05,0x6d,0x41, //2041 0x24,0xAd,0xB6, //2042 0x04,0x9B,0x4A, //2043 0x7A,0x4B,0xBe, //2044 0x0A,0x4B,0x51, //2045 0x0A,0xA5,0x46, //2046 0x5B,0x52,0xBA, //2047 0x06,0xd2,0x4e, //2048 0x0A,0xdA,0x42, //2049 0x35,0x5B,0x37, //2050 0x09,0x37,0x4B, //2051 0x84,0x97,0xC1, //2052 0x04,0x97,0x53, //2053 0x06,0x4B,0x48, //2054 0x66,0xA5,0x3C, //2055 0x0e,0xA5,0x4f, //2056 0x06,0xB2,0x44, //2057 0x4A,0xB6,0x38, //2058 0x0A,0xAe,0x4C, //2059 0x09,0x2e,0x42, //2060 0x3C,0x97,0x35, //2061 0x0C,0x96,0x49, //20620x0d,0x4A,0x51, //20640x0d,0xA5,0x45, //20650x55,0xAA,0xBA, //20660x05,0x6A,0x4e, //20670x0A,0x6d,0x43, //20680x45,0x2e,0xB7, //20690x05,0x2d,0x4B, //20700x8A,0x95,0xBf, //20710x0A,0x95,0x53, //20720x0B,0x4A,0x47, //20730x6B,0x55,0x3B, //20740x0A,0xd5,0x4f, //20750x05,0x5A,0x45, //20760x4A,0x5d,0x38, //20770x0A,0x5B,0x4C, //20780x05,0x2B,0x42, //20790x3A,0x93,0xB6, //20800x06,0x93,0x49, //20810x77,0x29,0xBd, //20820x06,0xAA,0x51, //20830x0A,0xd5,0x46, //20840x54,0xdA,0xBA, //20850x04,0xB6,0x4e, //20860x0A,0x57,0x43, //20870x45,0x27,0x38, //20880x0d,0x26,0x4A, //20890x8e,0x93,0x3e, //20900x0d,0x52,0x52, //20910x0d,0xAA,0x47, //20920x66,0xB5,0x3B, //20930x05,0x6d,0x4f, //20940x04,0xAe,0x45, //20950x4A,0x4e,0xB9, //20960x0A,0x4d,0x4C, //20970x0d,0x15,0x41, //20980x2d,0x92,0xB5, //2099};code uchar jieqi_code[]={0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1901 0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78, //19020x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78, //19030x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87, //19040x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1906 0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78, //1907 0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1908 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1909 0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1910 0x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0x78, //1911 0x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1912 0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1913 0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1914 0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78, //1915 0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1916 0x95,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87, //1917 0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77, //1918 0x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78, //1919 0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1920 0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87, //1921 0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x77, //1922 0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0x78, //1923 0x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1924 0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x87, //1925 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1926 0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78, //1927 0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1928 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1929 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1930 0x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0x78, //1931 0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1932 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1933 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1934 0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1935 0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1936 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1937 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1938 0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1939 0x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1940 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1941 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1942 0x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1943 0x96,0xA5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1944 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1945 0x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77, //1946 0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1947 0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //19480x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77, //1950 0x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0x78, //1951 0x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //1952 0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1953 0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x68,0x78,0x87, //1954 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1955 0x96,0xA5,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //1956 0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1957 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1958 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1959 0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87, //1960 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1961 0x96,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1962 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1963 0x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87, //1964 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1965 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1966 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1967 0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //1968 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1969 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1970 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0x77, //1971 0x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //1972 0xA5,0xB5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1973 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1974 0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0x77, //1975 0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x89,0x88,0x78,0x87,0x87, //1976 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //1977 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87, //1978 0x96,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77, //1979 0x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //1980 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x77,0x87, //1981 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1982 0x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0x77, //1983 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //1984 0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //1985 0xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //1986 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x69,0x78,0x87, //1987 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //1988 0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87, //1989 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87, //1990 0x95,0xB4,0x96,0xA5,0x86,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1991 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //19920xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1994 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x76,0x78,0x69,0x78,0x87, //1995 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //1996 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //1997 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //1998 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //1999 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2000 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2001 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2002 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //2003 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2004 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2005 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2006 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0x87, //2007 0x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2008 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2009 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2010 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0x87, //2011 0x96,0xB4,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2012 0xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //2013 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2014 0x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0x87, //2015 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //2016 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //2017 0xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2018 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87, //2019 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86, //2020 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2021 0xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0x87, //2022 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0x87, //2023 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2024 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2025 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2026 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2027 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2028 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x86, //2029 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //2030 0xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0x87, //2031 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //2032 0xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x86, //2033 0xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x78,0x88,0x78,0x87,0x87, //2034 0xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //2035 0x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //20360xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //20380xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //20390x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x96, //20400xA5,0xC3,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //20410xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0x87, //20420xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //20430x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x88,0x87,0x96, //20440xA5,0xC3,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0x86, //20450xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0x87, //20460xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0x87, //20470x95,0xB4,0xA5,0xB4,0xA5,0xA5,0x97,0x87,0x87,0x88,0x86,0x96, //20480xA4,0xC3,0xA5,0xA5,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0x86, //20490xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x78,0x78,0x87,0x87, //2050 };///月份数据表code uchar day_code1[9]={0x0,0x1f,0x3b,0x5a,0x78,0x97,0xb5,0xd4,0xf3};code uint day_code2[3]={0x111,0x130,0x14e};code uchar jieqi_name[][3]={"hi","xh","dh","lc","ys","jz","cf","qm","gy","lx","xm","mz","xz","xs","ds","lq","cs ","bl","qf","hl","sj","ld","xx","dx","dz",};code uchar gjieri_name[][2]={"hi","yd","fn","ld","qn","et","jj","js","gq",};code uchar njieri_name[][2]={"hi","cj","yx","dw","qx","zq","cy","lb",};/*函数功能:输入BCD阳历数据,输出BCD阴历数据(只允许1901-2099年)调用函数示例:Conversion(c_sun,year_sun,month_sun,day_sun)如:计算2004年10月16日Conversion(0,0x4,0x10,0x16);c_sun,year_sun,month_sun,day_sun均为BCD数据,c_sun为世纪标志位,c_sun=0为21世纪,c_sun=1为19世纪调用函数后,原有数据不变,读c_moon,year_moon,month_moon,day_moon得出阴历BCD数据*/data uchar year_moon,month_moon,day_moon,week;uchar qi=0,gri=0,nri=0;void jieqi (uchar *nyr){uint temp,yy,dd,mm,addr,y;uchar mo,ndd;yy=nyr[0]*100+nyr[1];mm=nyr[2];dd=nyr[3];y = yy-1901;mo=month_moon/16*10+month_moon%16;ndd=day_moon/16*10+day_moon%16;addr=y*12+mm-1;if(dd<15){temp=15-dd;if((jieqi_code[addr]>>4)==temp) qi=mm*2-1;else qi=0;}if(dd==15) qi=0;if(dd>15){temp=dd-15;if((jieqi_code[addr]&0x0f)==temp) qi=mm*2;else qi=0;}shijian[3]=qi;////////////////////////////////////////////////////////////////////////////////// LCD_write_char(10,1,' ');LCD_write_char(11,1,jieqi_name[qi][0]);LCD_write_char(12,1,jieqi_name[qi][1]);LCD_write_char(13,1,' ');if(mm==1&&dd==1) gri=1;if(mm==3&&dd==8) gri=2;if(mm==5&&dd==1) gri=3;if(mm==5&&dd==4) gri=4;if(mm==6&&dd==1) gri=5;if(mm==8&&dd==1) gri=6;if(mm==9&&dd==10) gri=7;if(mm==10&&dd==1) gri=8;if(mo==1&&ndd==1) nri=1;if(mo==1&&ndd==15) nri=2;if(mo==5&&ndd==5) nri=3;if(mo==7&&ndd==7) nri=4;if(mo==8&&ndd==15) nri=5;if(mo==9&&ndd==9) nri=6;if(mo==12&&ndd==8) nri=7;/*********************************************************/shijian[4]=gri;shijian[5]=nri;/**********************************************************/if(nri!=0){LCD_write_char(14,1,njieri_name[nri][0]);LCD_write_char(15,1,njieri_name[nri][1]);}else{LCD_write_char(14,1,gjieri_name[gri][0]);LCD_write_char(15,1,gjieri_name[gri][1]);}}bit c_moon;/*子函数,用于读取数据表中农历月的大月或小月,如果该月为大返回1,为小返回0*/ bit get_moon_day(uchar month_p,uint table_addr){uchar temp;switch (month_p){case 1:{temp=year_code[table_addr]&0x08;if (temp==0)return(0);else return(1);}case 2:{temp=year_code[table_addr]&0x04;if (temp==0)return(0);else return(1);}case 3:{temp=year_code[table_addr]&0x02;if (temp==0)return(0);else return(1);}case 4:{temp=year_code[table_addr]&0x01;if (temp==0)return(0);else return(1);}case 5:{temp=year_code[table_addr+1]&0x80;if (temp==0) return(0);else return(1);}case 6:{temp=year_code[table_addr+1]&0x40;if (temp==0)return(0);else return(1);}case 7:{temp=year_code[table_addr+1]&0x20;if (temp==0)return(0);else return(1);}case 8:{temp=year_code[table_addr+1]&0x10;if (temp==0)return(0);else return(1);}case 9:{temp=year_code[table_addr+1]&0x08;if (temp==0)return(0);else return(1);}case 10:{temp=year_code[table_addr+1]&0x04;if (temp==0)return(0);else return(1);}case 11:{temp=year_code[table_addr+1]&0x02;if (temp==0)return(0);else return(1);}case 12:{temp=year_code[table_addr+1]&0x01;if (temp==0)return(0);else return(1);}case 13:{temp=year_code[table_addr+2]&0x80;if (temp==0)return(0);else return(1);}}}/*函数功能:输入BCD阳历数据,输出BCD阴历数据(只允许1901-2099年)调用函数示例:Conversion(c_sun,year_sun,month_sun,day_sun)如:计算2004年10月16日Conversion(0,0x4,0x10,0x16);c_sun,year_sun,month_sun,day_sun均为BCD数据,c_sun为世纪标志位,c_sun=0为21世纪,c_sun=1为19世纪调用函数后,原有数据不变,读c_moon,year_moon,month_moon,day_moon得出阴历BCD数据*/void Conversion(bit c,uchar year,uchar month,uchar day){ //c=0 为21世纪,c=1 为19世纪输入输出数据均为BCD数据uchar temp1,temp2,temp3,month_p;uint temp4,table_addr;bit flag2,flag_y;temp1=year/16; //BCD->hex 先把数据转换为十六进制temp2=year%16;year=temp1*10+temp2;temp1=month/16;temp2=month%16;month=temp1*10+temp2;temp1=day/16;temp2=day%16;day=temp1*10+temp2;//定位数据表地址if(c==0){table_addr=(year+0x64-1)*0x3;}else{table_addr=(year-1)*0x3;}//定位数据表地址完成//取当年春节所在的公历月份temp1=year_code[table_addr+2]&0x60;temp1=_cror_(temp1,5);//取当年春节所在的公历月份完成//取当年春节所在的公历日temp2=year_code[table_addr+2]&0x1f;//取当年春节所在的公历日完成// 计算当年春年离当年元旦的天数,春节只会在公历1月或2月if(temp1==0x1){temp3=temp2-1;}else{temp3=temp2+0x1f-1;}// 计算当年春年离当年元旦的天数完成//计算公历日离当年元旦的天数,为了减少运算,用了两个表//day_code1[9],day_code2[3]//如果公历月在九月或前,天数会少于0xff,用表day_code1[9],//在九月后,天数大于0xff,用表day_code2[3]//如输入公历日为8月10日,则公历日离元旦天数为day_code1[8-1]+10-1//如输入公历日为11月10日,则公历日离元旦天数为day_code2[11-10]+10-1if (month<10){temp4=day_code1[month-1]+day-1;}else{temp4=day_code2[month-10]+day-1;}if ((month>0x2)&&(year%0x4==0)){ //如果公历月大于2月并且该年的2月为闰月,天数加1temp4+=1;}//计算公历日离当年元旦的天数完成//判断公历日在春节前还是春节后if (temp4>=temp3){ //公历日在春节后或就是春节当日使用下面代码进行运算temp4-=temp3;month=0x1;month_p=0x1; //month_p为月份指向,公历日在春节前或就是春节当日month_p指向首月flag2=get_moon_day(month_p,table_addr);//检查该农历月为大小还是小月,大月返回1,小月返回0flag_y=0;if(flag2==0)temp1=0x1d; //小月29天else temp1=0x1e; //大小30天temp2=year_code[table_addr]&0xf0;temp2=_cror_(temp2,4); //从数据表中取该年的闰月月份,如为0则该年无闰月while(temp4>=temp1){temp4-=temp1;month_p+=1;if(month==temp2){flag_y=~flag_y;if(flag_y==0)month+=1;}else month+=1;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temp1=0x1d;else temp1=0x1e;}day=temp4+1;}else{ //公历日在春节前使用下面代码进行运算temp3-=temp4;if (year==0x0){year=0x63;c=1;}else year-=1;table_addr-=0x3;month=0xc;temp2=year_code[table_addr]&0xf0;temp2=_cror_(temp2,4);if (temp2==0)month_p=0xc;elsemonth_p=0xd; ///*month_p为月份指向,如果当年有闰月,一年有十三个月,月指向13,无闰月指向12*/ flag_y=0;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temp1=0x1d;else temp1=0x1e;while(temp3>temp1){temp3-=temp1;month_p-=1;if(flag_y==0)month-=1;if(month==temp2)flag_y=~flag_y;flag2=get_moon_day(month_p,table_addr);if(flag2==0)temp1=0x1d;else temp1=0x1e;}day=temp1-temp3+1;}c_moon=c; //HEX->BCD ,运算结束后,把数据转换为BCD数据temp1=year/10;temp1=_crol_(temp1,4);temp2=year%10;year_moon=temp1|temp2;temp1=month/10;temp1=_crol_(temp1,4);temp2=month%10;month_moon=temp1|temp2;temp1=day/10;temp1=_crol_(temp1,4);temp2=day%10;day_moon=temp1|temp2;}/*函数功能:输入BCD阳历数据,输出BCD星期数据(只允许1901-2099年)调用函数示例:Conver_week(c_sun,year_sun,month_sun,day_sun)如:计算2004年10月16日Conversion(0,0x4,0x10,0x16);c_sun,year_sun,month_sun,day_sun均为BCD数据,c_sun为世纪标志位,c_sun=0为21世纪,c_sun=1为19世纪调用函数后,原有数据不变,读week得出阴历BCD数据*/code uchar table_week[12]={0,3,3,6,1,4,6,2,5,0,3,5}; //月修正数据表/*算法:日期+年份+所过闰年数+月较正数之和除7 的余数就是星期但如果是在闰年又不到3 月份上述之和要减一天再除7星期数为0*/void Conver_week(bit c,uchar year,uchar month,uchar day){//c=0 为21世纪,c=1 为19世纪输入输出数据均为BCD数据uchar temp1,temp2;temp1=year/16; //BCD->hex 先把数据转换为十六进制temp2=year%16;year=temp1*10+temp2;temp1=month/16;temp2=month%16;month=temp1*10+temp2;temp1=day/16;temp2=day%16;day=temp1*10+temp2;if (c==0){year+=0x64;} //如果为21世纪,年份数加100temp1=year/0x4; //所过闰年数只算1900年之后的temp2=year+temp1;temp2=temp2%0x7; //为节省资源,先进行一次取余,避免数大于0xff,避免使用整型数据temp2=temp2+day+table_week[month-1];if (year%0x4==0&&month<3)temp2-=1;week=temp2%0x7;}//testuchar c_sun,year_sun,month_sun,day_sun;/***********************************************农历转换函数************************************************/unsigned char set_1[4];bit flag_1=0,flag_2=0;void nongli(uchar *nyr){uchar i=0;code uchar table_week[][4]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};year_sun=nyr[1]/10*16+nyr[1]%10;month_sun=nyr[2]/10*16+nyr[2]%10;day_sun=nyr[3]/10*16+nyr[3]%10;//LCD_clear();if(nyr[0]==20){LCD_write_char(0,1,'2');LCD_write_char(1,1,'0');Conversion(0,year_sun,month_sun,day_sun);Conver_week(0,year_sun,month_sun,day_sun);}else if(nyr[0]==19){LCD_write_char(0,1,'1');LCD_write_char(1,1,'9');Conversion(1,year_sun,month_sun,day_sun);Conver_week(1,year_sun,month_sun,day_sun);}else{LCD_write_str(0,1,"Error Input!");sound_3();delay1(200);delay1(200);delay1(200);delay1(200);delay1(200);delay1(200);flag_1=1;return;}LCD_write_char(2,1,year_moon/16+0x30);LCD_write_char(3,1,year_moon%16+0x30);LCD_write_char(4,1,'-');LCD_write_char(5,1,month_moon/16+0x30);LCD_write_char(6,1,month_moon%16+0x30);LCD_write_char(7,1,'-');LCD_write_char(8,1,day_moon/16+0x30);LCD_write_char(9,1,day_moon%16+0x30);LCD_write_str(10,1," ");LCD_write_str(12,0,table_week[week%16]);}/*************************************************接受要转换成农历个阳历的年月日函数**************************************************/void receive(){unsigned char i;LCD_clear();//清屏key_value=16;ds1302_read_time();for(i=0;i<4;i++)set_1[i]=time_buf1[i];set_1[0]=20;LCD_write_char(0,0,set_1[0]/10+0x30);LCD_write_char(1,0,set_1[0]%10+0x30);LCD_write_char(2,0,set_1[1]/10+0x30);LCD_write_char(3,0,set_1[1]%10+0x30);LCD_write_char(4,0,'-');LCD_write_char(5,0,set_1[2]/10+0x30);LCD_write_char(6,0,set_1[2]%10+0x30);LCD_write_char(7,0,'-');LCD_write_char(8,0,set_1[3]/10+0x30);LCD_write_char(9,0,set_1[3]%10+0x30);nongli(set_1);i=0;LCD_write_com(0x0f);//打开光标LCD_write_com(0x80+i);//写入初始地址while(1){key();if((key_value>=0)&&(key_value<=9)){while(1){keyscan();if(!keydown){delay1(10);keyscan();if(!keydown){LCD_write_Data(key_value+0x30);LCD_write_com(0x80+i);//校正写数据时数据指针的加一if(i==0){set_1[0]=key_value*10+set_1[0]%10;key_value=16;break;}if(i==1){set_1[0]=key_value+set_1[0]/10*10;key_value=16;break;}if(i==2)//年份{set_1[1]=key_value*10+set_1[1]%10;key_value=16;break;}if(i==3){set_1[1]=key_value+set_1[1]/10*10;key_value=16;break;}if(i==4)//'-'符号不变{LCD_write_Data('-');LCD_write_com(0x80+i);//校正写数据时数据指针的加一key_value=16;break;}if(i==5)//月份{set_1[2]=key_value*10+set_1[2]%10;key_value=16;break;}if(i==6){set_1[2]=key_value+set_1[2]/10*10;key_value=16;break;}if(i==7)//'-'符号不变{LCD_write_Data('-');LCD_write_com(0x80+i);//校正写数据时数据指针的加一key_value=16;break;}if(i==8)//年份{set_1[3]=key_value*10+set_1[3]%10;key_value=16;break;}if(i==9){set_1[3]=key_value+set_1[3]/10*10;key_value=16;break;}}}}}if(key_value==12){while(1){keyscan();if(!keydown){delay1(10);keyscan();if(!keydown){flag_2=1;key_value=16;break;}}}break;}if(key_value==13){while(1){keyscan();if(!keydown){delay1(10);keyscan();if(!keydown){if((i>0)&&(i<=9))i--;LCD_write_com(0x80+i);key_value=16;break;}}}}if(key_value==14){while(1){keyscan();if(!keydown){delay1(10);keyscan();if(!keydown){if(i<9)i=i+1;LCD_write_com(0x80+i);key_value=16;break;}}}。
C 万年历及公历农历转换源代码1
scanf("%d.%d.%d",&gyear,&gmonth,&gday); if(gyear%4==0 && gyear%100!=0 || gyear%400==0) months[2]=29; else months[2]=28; /*以下是计算在该公历年的第几天*/
whatday=gPastday[gmonth]+gday; if((gyear%4==0 && gyear%100!=0 || gyear%400==0) && (gmonth>2)) whatday++; /*上如果是闰年和月份大于二则在该公历年的第几天数+1*/ /*计算该年春节在公历年的第几天*/
clrscr();
}
}
getch();
}
/*公历每月前面的天数*/ const int gPastday[13]={0,0,31,59,90,120,151,181,212,243,273,304,334};
months[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};
{case 1:printf("
* 1 * "); break;
case 3:printf("
* 3 * "); break;
case 5:printf("
* 5 * "); break;
case 7:printf("
* 7 * "); break;
case 9:printf("
* 9 * ");break;
{
公历转换成农历c语言函数
公历转换成农历c语言函数在进行农历与公历的转换时,使用C语言编写一个函数可以很方便地实现这一功能。
本文将为您介绍一个简单而有效的公历转换成农历的C语言函数。
函数名称:solarToLunar功能:将公历日期转换成农历日期输入参数:int year(公历年份),int month(公历月份),int day (公历日)返回值:char*(农历日期)```c#include<stdio.h>#include<stdlib.h>// 农历数据结构体typedef struct LunarDate {int year;int month;int day;} LunarDate;// 公历转换成农历函数char* solarToLunar(int year, int month, int day) {/* 在这里编写您的代码 */}int main() {int year, month, day;printf("请输入公历年份:");scanf("%d", &year);printf("请输入公历月份:");scanf("%d", &month);printf("请输入公历日期:");scanf("%d", &day);char* lunarDate = solarToLunar(year, month, day); printf("农历日期:%s\n", lunarDate);free(lunarDate); // 释放内存return 0;}```在程序中,我们使用了一个结构体LunarDate来表示农历日期,它包含了年、月、日三个变量。
函数solarToLunar负责将公历日期转换成农历日期,并以字符串形式返回。
接下来,我们需要在函数solarToLunar中编写转换逻辑。
用c语言编写万年历思路
用c语言编写万年历思路摘要:一、万年历的概念及用途1.万年历的定义2.万年历的用途二、用C语言编写万年历的思路1.确定编写目标2.分析万年历的组成结构3.编写C语言程序实现万年历功能4.测试与优化三、万年历编写的具体步骤1.定义数据结构2.计算天数3.生成日历4.输出结果四、编写万年历的注意事项1.闰年的处理2.月份与星期的转换3.输出的格式正文:一、万年历的概念及用途万年历,又称历书,是一种历法书籍。
它详细地记录了每一年的阳历、阴历、节气、朔望等天文数据,方便人们查询和对照。
在我国,万年历有着悠久的历史,被广泛用于农业、民俗、天文观测等领域。
二、用C语言编写万年历的思路1.确定编写目标:使用C语言编写一个具有查询功能的万年历程序,方便用户查询日历、节日等信息。
2.分析万年历的组成结构:万年历主要包括阳历、阴历、节气、朔望等部分。
首先需要确定各个部分的数据结构,然后计算相关数据。
3.编写C语言程序实现万年历功能:根据分析结果,编写C语言程序,计算并生成万年历。
4.测试与优化:对编写好的程序进行测试,确保其正确性。
在测试过程中,针对发现的问题进行优化,提高程序的性能。
三、万年历编写的具体步骤1.定义数据结构:为了便于编写程序,需要先定义相关的数据结构。
例如,可以用数组表示年份的闰年情况,用结构体表示日历等。
2.计算天数:根据公历、农历的计算方法,计算某一年或某一个月的天数。
这涉及到闰年的判断、月份与星期的转换等计算。
3.生成日历:根据计算出的天数,生成日历。
这一步需要将日历按照一定的格式输出,例如,按照周或月为单位进行分组。
4.输出结果:将生成的日历输出到屏幕或文件中,供用户查看。
四、编写万年历的注意事项1.闰年的处理:闰年的判断方法有多种,需要根据实际情况选择合适的算法。
在C语言程序中,可以使用if语句进行闰年的判断。
2.月份与星期的转换:在计算天数的过程中,需要将月份与星期进行转换。
例如,某个月的1号可能是上一年的最后一天,也可能是这一年的第一天。
c语言公历转农历算法
c语言公历转农历算法
公历和农历是两种不同的历法系统,公历是以太阳运行为基础的历法,而农历则是以月亮运行为基础的历法。
在一些特殊的场合,我们
可能需要将公历日期转换为农历日期,这就需要用到C语言编写的公
历转农历算法。
公历转农历的算法可以分为两个步骤:首先是计算公历日期到农历
起始点(即农历1900年1月31日)的天数差,然后根据这个天数差计算出对应的农历日期。
首先,我们需要定义一个结构体来表示农历日期,包括年、月、日
和是否闰月等信息。
然后,我们可以编写一个函数来计算公历日期到
农历起始点的天数差。
这个函数可以使用公历日期的年、月、日作为
参数,然后通过一系列的计算来得到天数差。
接下来,我们可以编写另一个函数来根据天数差计算出对应的农历
日期。
这个函数可以使用一个数组来存储每个农历年的天数,然后根
据天数差逐步减去每个农历年的天数,直到找到对应的农历年份。
然后,再根据剩余的天数计算出对应的农历月份和日期。
最后,我们可以在主函数中调用这两个函数来完成公历日期到农历
日期的转换。
我们可以输入一个公历日期,然后调用第一个函数计算
出天数差,再调用第二个函数计算出对应的农历日期,并将结果输出。
需要注意的是,由于农历的特殊性,每个农历年的天数和月份都是不固定的,而且还有闰月的情况。
因此,在编写算法时需要考虑到这些特殊情况,并进行相应的处理。
总之,C语言公历转农历算法是一个比较复杂的问题,需要考虑到公历和农历的差异以及农历的特殊性。
通过合理的算法设计和编程实现,我们可以实现公历日期到农历日期的转换,从而满足一些特殊场合的需求。
C#转换农历的简单方法
C#转换农历的简单方法AD:C#转换农历原来还准备自己写算法,并研究农历规则。
发现那太难和麻烦了,光是农历的推算那就我等专门研究历法的人一下搞懂的。
后来发现.NET类库也提供一些基础的农历类System.Globalization.ChineseLunisolarCalendar。
改装了一下如DateTime时间形式,实现了公历农历转换的功能,但是只能算到1900~2100年之间的。
基本够日常使用了。
C#转换农历代码如下:1usingSystem;2usingSystem.Collections.Generic;3usingSystem.Text;45namespaceSystem6...{7/**////<summary>8///中国常用农历日期时间类9///zj53hao@/zj53hao10///</summary>11classChinaDateTime12...{13privateintyear,month,dayOfMonth;14privateboolisLeap;15publicDateTimetime;1617/**////<summary>18///获取当前日期的农历年19///</summary>20publicintYear21...{22get...{returnyear;}23}2425/**////<summary>26///获取当前日期的农历月份27///</summary>28publicintMonth29...{30get...{returnmonth;}31}3233/**////<summary>34///获取当前日期的农历月中天数35///</summary>36publicintDayOfMonth37...{38get...{returndayOfMonth;}39}4041/**////<summary>42///获取当前日期是否为闰月中的日期43///</summary>44publicboolIsLeap45...{46get...{returnisLeap;}47}4849System.Globalization.ChineseLunisolarCalendarcc;50/**////<summary>51///返回指定公历日期的阴历时间52///</summary>53///<paramname paramname="time"></param>54publicChinaDateTime(DateTimetime)55...{56cc=newSystem.Globalization.ChineseLunisolarCalendar();5758if(time>cc.MaxSupportedDateTime||time<cc.MinSupportedDateTime) 59thrownewException("参数日期时间不在支持的范围内,支持范围:"+cc.MinSupportedDateTime.ToShortDateString()+"到"+cc.MaxSupportedDateTime.ToShortDateString());60year=cc.GetYear(time);61month=cc.GetMonth(time);62dayOfMonth=cc.GetDayOfMonth(time);63isLeap=cc.IsLeapMonth(year,month);64if(isLeap)month-=1;65this.time=time;6667}。
c 农历年月日程序设计
c 农历年月日程序设计C语言是一种广泛应用于计算机科学和软件开发领域的编程语言,其强大的功能和灵活的语法使其成为许多程序员的首选。
在C语言中,我们可以通过编写程序来实现农历年月日的计算和转换。
下面我们就以C语言编写农历年月日程序为例,来介绍一下具体的实现方法。
我们需要了解农历的基本知识。
农历是一种以月亮的运行周期为基础的历法,与阳历有所不同。
农历的年份通常由十二个动物的名称来表示,而月份和日期则采用数字来表示。
农历的计算涉及到一些复杂的算法和规则,但是我们可以利用已有的算法库来简化这一过程。
在C语言中,我们可以使用time.h头文件中的函数来获取当前的日期和时间。
具体的操作步骤如下:1. 引入头文件:首先,我们需要在程序中引入time.h头文件,以便使用其中的日期和时间相关函数。
```c#include <time.h>```2. 获取当前的日期和时间:我们可以使用time函数来获取当前的日期和时间,并将其保存在一个time_t类型的变量中。
```ctime_t t = time(NULL);```3. 将日期和时间转换为本地时间:由于time函数返回的是UTC时间(世界标准时间),我们需要将其转换为本地时间。
可以使用localtime函数来实现这一转换。
```cstruct tm *local = localtime(&t);```4. 获取年月日信息:通过local结构体中的成员变量,我们可以获取当前的年份、月份和日期。
```cint year = local->tm_year + 1900;int month = local->tm_mon + 1;int day = local->tm_mday;```5. 将日期转换为农历日期:最后,我们可以使用算法库或自定义的算法将公历日期转换为农历日期。
这里我们以调用算法库为例。
```c// 假设已经定义了一个函数lunar_calendar,用于将公历日期转换为农历日期int lunar_year, lunar_month, lunar_day;lunar_calendar(year, month, day, &lunar_year, &lunar_month, &lunar_day);```通过以上的步骤,我们就可以在C语言中实现农历年月日的计算和转换了。
(2023)C语言万年历设计报告(一)
(2023)C语言万年历设计报告(一)C语言万年历设计报告这份报告是针对 2023 年度 C 语言万年历设计而准备的。
设计目的该万年历的设计目的是为了让用户能够快速地查看任意公历年份的日历,同时还能够显示节气、万年历和日历信息。
设计思路该万年历的主要思路是通过用户输入任意公历年份,在程序中计算并显示该年的日历信息。
具体实现思路如下:1.用户输入年份信息。
2.程序判断该年份是否为闰年,并计算该年的总天数。
3.根据该年第一天是星期几,排列该年每个月的天数。
4.标记国历节日,如元旦、劳动节等。
5.计算并标记该年的节气,如立春、清明等。
6.计算并标记该年的重要万年历信息,如“三伏”、“四季”等。
设计要点在实现该万年历的过程中需要注意以下几个要点:1.为了代码的可维护性,尽量将每个功能模块拆分成函数的形式。
2.程序中需要处理日期的加减运算,可以使用标准库中的<time.h>。
3.节气和万年历的计算应该基于一些公式而不是硬编码。
设计结果经过实现,该万年历已经能够正常运行,并能够正确地显示各种信息。
用户输入任意公历年份后,程序可以迅速计算并展示该年的万年历、节气和重要节日信息。
结论通过本次 C 语言万年历的设计,我们不仅深入地了解了日期处理等相关知识,还提升了编码的能力。
在日常开发中,我们也可以根据这些基础知识,设计更为实用的应用程序。
可改进之处尽管该万年历已经能够满足基本的需求,但仍有一些改进空间。
例如:1.目前仅支持公历,可以添加其他历法的支持,如农历、阴阳历等。
2.界面可以进一步美化,增加更多交互性的组件,如按钮、下拉菜单等。
3.可以添加更多的功能,如查询特定日期的天气、星座运势等。
总结本次 C 语言万年历设计,使我们更好地理解了日期处理的相关知识,提高了我们的编码水平。
同时,我们也意识到在实际项目中,需要更多的功能和优化,才能更好地服务于用户的需求。
通过持续不断的学习和实践,我们可以不断提升自己的编程技能。
二十四节气的C语言算法
【算法】二十四节气的C语言算法2009-05-27 23:12二十四节气是我国劳动人民创造的辉煌文化,它能反映季节的变化,指导农事活动,影响着千家万户的衣食住行。
有人认为二十四节气从属农历,其实,它是根据阳历划定的。
即根据太阳在黄道上的位置,把一年划分为24个彼此相等的段落。
也就是把黄道分成24个等份,每等份各占黄经15°。
由于太阳通过每等份所需的时间几乎相等,二十四节气的公历日期每年大致相同:上半年在6日、21日前后,下半年在8日、23日前后。
节气需要存表,没有固定规律,数据来源别人的VB程序,查询程序是自己写的。
如下:/******************************************************************** ********************************************************函数功能:二十四节气数据库入口参数: unsigned char(yy,mo,dd) 对应年月日出口参数: unsigned char(0-24) 1-24对应二十四节气作者: TOTOP二十四节气数据库(1901--2050)数据格式说明:如1901年的节气为1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月[ 6,21][ 4,19][ 6,21][ 5,21][ 6,22][ 6,22][ 8,23][ 8,24][ 8,24][ 8,24][ 8,23][ 8,22][ 9, 6][11, 4][ 9, 6][10, 6][ 9, 7][ 9, 7][ 7, 8][ 7, 9][ 7, 9][ 7, 9][ 7, 8][ 7,15]上面第一行数据为每月节气对应公历日期,15减去每月第一个节气,每月第二个节气减去15得第二行,这样每月两个节气对应数据都小于16,每月用一个字节存放,高位存放第一个节气数据,低位存放第二个节气的数据,可得下表********************************************************************* *******************************************************/uchar code jieqi_code[]={0x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19010x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0 x78, //19020x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0 x78, //19030x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0 x87, //19040x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19050x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19060x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0 x78, //19070x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19080x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19090x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19100x96,0xA5,0x87,0x96,0x87,0x87,0x79,0x69,0x69,0x69,0x78,0 x78, //19110x86,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19120x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19130x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19140x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0 x78, //19150x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //1916x87, //19170x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x77, //19180x96,0xA5,0x97,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0 x78, //19190x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19200x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0 x87, //19210x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x77, //19220x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x69,0x69,0x78,0 x78, //19230x96,0xA5,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19240x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0 x87, //19250x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19260x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0 x78, //19270x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19280x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19290x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19300x96,0xA4,0x96,0x96,0x97,0x87,0x79,0x79,0x79,0x69,0x78,0 x78, //19310x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19320x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19330x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19340x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19350x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19360x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19370x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //1938x78, //19390x96,0xA5,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19400x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19410x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19420x96,0xA4,0x96,0x96,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19430x96,0xA5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19440x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19450x95,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0 x77, //19460x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19470x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //19480xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x79,0x77,0 x87, //19490x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0 x77, //19500x96,0xB4,0x96,0xA6,0x97,0x97,0x79,0x79,0x79,0x69,0x78,0 x78, //19510x96,0xA5,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //19520xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19530x95,0xB4,0x96,0xA5,0x96,0x97,0x78,0x79,0x78,0x68,0x78,0 x87, //19540x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19550x96,0xA5,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //19560xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19570x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19580x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19590x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0 x87, //1960x87, //19610x96,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19620x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19630x96,0xA4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0 x87, //19640xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19650x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19660x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19670x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //19680xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19690x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19700x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x79,0x69,0x78,0 x77, //19710x96,0xA4,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //19720xA5,0xB5,0x96,0xA5,0xA6,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19730x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19740x96,0xB4,0x96,0xA6,0x97,0x97,0x78,0x79,0x78,0x69,0x78,0 x77, //19750x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x89,0x88,0x78,0x87,0 x87, //19760xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //19770x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0 x87, //19780x96,0xB4,0x96,0xA6,0x96,0x97,0x78,0x79,0x78,0x69,0x78,0 x77, //19790x96,0xA4,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //19800xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x77,0 x87, //19810x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //1982x77, //19830x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x87, //19840xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //19850xA5,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //19860x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x79,0x78,0x69,0x78,0 x87, //19870x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //19880xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0 x87, //19890xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0 x87, //19900x95,0xB4,0x96,0xA5,0x86,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19910x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //19920xA5,0xB3,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0 x87, //19930xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19940x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x76,0x78,0x69,0x78,0 x87, //19950x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //19960xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //19970xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //19980x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //19990x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //20000xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //20010xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //20020x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //20030x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //2004x87, //20050xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20060x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x69,0x78,0 x87, //20070x96,0xB4,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x87,0x78,0x87,0 x86, //20080xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //20090xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20100x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x78,0 x87, //20110x96,0xB4,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0 x86, //20120xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x87, //20130xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20140x95,0xB4,0x96,0xA5,0x96,0x97,0x88,0x78,0x78,0x79,0x77,0 x87, //20150x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0 x86, //20160xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x87, //20170xA5,0xB4,0xA6,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20180xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0 x87, //20190x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x86, //20200xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //20210xA5,0xB4,0xA5,0xA5,0xA6,0x96,0x88,0x88,0x88,0x78,0x87,0 x87, //20220xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x79,0x77,0 x87, //20230x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x96, //20240xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //20250xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //2026x87, //20270x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x96, //20280xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //20290xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //20300xA5,0xB4,0x96,0xA5,0x96,0x96,0x88,0x78,0x78,0x78,0x87,0 x87, //20310x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x96, //20320xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x86, //20330xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x78,0x88,0x78,0x87,0 x87, //20340xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20350x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x96, //20360xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x86, //20370xA5,0xB3,0xA5,0xA5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //20380xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20390x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x78,0x87,0 x96, //20400xA5,0xC3,0xA5,0xB5,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0 x86, //20410xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x88,0x88,0x88,0x78,0x87,0 x87, //20420xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20430x95,0xB4,0xA5,0xB4,0xA5,0xA6,0x97,0x87,0x87,0x88,0x87,0 x96, //20440xA5,0xC3,0xA5,0xB4,0xA5,0xA6,0x87,0x88,0x87,0x78,0x87,0 x86, //20450xA5,0xB3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x88,0x78,0x87,0 x87, //20460xA5,0xB4,0x96,0xA5,0xA6,0x96,0x88,0x88,0x78,0x78,0x87,0 x87, //20470x95,0xB4,0xA5,0xB4,0xA5,0xA5,0x97,0x87,0x87,0x88,0x86,0 x96, //2048x86, //20490xA5,0xC3,0xA5,0xB5,0xA6,0xA6,0x87,0x88,0x78,0x78,0x87,0 x87, //2050};unsigned char jieqi (unsigned char yy,mo,dd){unsigned char temp,y,d,m;int addr;d =dd; m =mo;y = yy-1901;addr=y*12+m-1;if(d<15){temp=15-d;if((jieqi_code[addr]>>4)==temp) return (m<<1-1);else return (0);}if(d==15) return (0);if(d>15){temp=d-15;if((jieqi_code[addr]&0x0f)==temp) return (m<<1);else return (0);}}。
阴历年月 24节气的算法 c语言
int GetWeek(int nYear,int nMonth,int nDay,int nWeekOfFirstday) // 4
{
int nDaysYear[]={31,28,31,30,31,30,31,31,30,31,30,31};
int nDaysLeapYear[]={31,29,31,30,31,30,31,31,30,31,30,31};
nWeek=GetWeek(nYear,nMonth,nDay,nWeekOfFirstday); // 4
isleapyear=IsLeapYear(nYear); // 2
}
int IsLeapYear(int nYear) // 2
{
if(nYear%4==0)
return 1;
else
return 0;
}
int GetWeekOfFirstday(int nYear) // 3
{
int i,j;
printf("the calender of this month as following:\n");
printf("*********************************\n");
printf(" SUN MON TUE WEN THU FRI STA\n");
{
if(nYear>2000)
return ((nYear-2001)*365+(nYear-2001)/4+1)%7;
else if(nYear<2000)
return 6-((2000-nYear)*365+(2000-nYear)/4)%7;
万年历c语言代码讲解
万年历c语言代码讲解摘要:一、万年历C语言代码讲解简介1.万年历的概念及用途2.C语言代码讲解的重要性二、C语言代码基础1.C语言简介2.C语言基本语法3.C语言的数据类型与变量三、万年历C语言代码实现1.计算闰年2.计算月份的天数3.计算日期的星期4.输出万年历四、万年历C语言代码的优化与拓展1.代码性能优化2.功能的拓展与实现五、总结1.万年历C语言代码讲解的意义2.对编程能力的提升正文:一、万年历C语言代码讲解简介万年历是一种记录了公历日期的工具,它可以帮助我们快速查询公历日期对应的农历、节日、提醒等信息。
C语言是一种广泛应用于计算机领域的编程语言,掌握C语言编程对于学习其他编程语言有很大的帮助。
本文将详细讲解万年历C语言代码的实现过程,帮助读者更好地理解C语言编程。
二、C语言代码基础1.C语言简介C语言是一种高级编程语言,由丹尼斯·里奇(Dennis Ritchie)于20世纪70年代在贝尔实验室开发。
C语言具有良好的性能和可移植性,被广泛应用于操作系统、嵌入式系统、硬件驱动等领域。
2.C语言基本语法C语言的基本语法包括变量声明、数据类型、运算符、控制结构、函数等。
了解这些基本语法对于编写C语言代码至关重要。
3.C语言的数据类型与变量C语言的数据类型包括整型、浮点型、字符型等。
变量是存储数据的容器,通过变量名来表示。
声明变量时需要指定变量的数据类型和存储空间。
三、万年历C语言代码实现1.计算闰年闰年是指公历年份可以被4整除但不能被100整除的年份,或者是可以被400整除的年份。
通过编写一个函数,我们可以判断一个年份是否为闰年。
2.计算月份的天数根据公历规定,每个月的天数不同。
通过编写一个函数,我们可以计算指定月份的天数。
3.计算日期的星期通过编写一个函数,我们可以根据公历日期计算对应的星期。
4.输出万年历根据用户输入的日期范围,输出对应的万年历信息。
四、万年历C语言代码的优化与拓展1.代码性能优化在实现万年历C语言代码的过程中,可以通过优化算法、使用更高效的函数等方式提高代码性能。
