C语言练习笔记:计算日期程序编写
来源:互联网 发布:北航大运村网络 编辑:程序博客网 时间:2024/05/22 07:09
#include <stdio.h>
#include <stdlib.h>
struct date{
int day;
int month;
int year;
};
int total=0;
int countday(const int *n,struct date m);
int main()
{
inty[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int ch;
struct date getdate;
printf("请输入你的日期/n");
scanf("%d%d%d",&getdate.year,&getdate.month,&getdate.day);
if(getdate.month>12&&getdate.month<0)
{
printf("请输入正确的月份/n");
scanf("%d",&getdate.month);
if(getdate.day>31&&getdate.day<0)
{
printf("请重新输入,在1~31范围内/n");
scanf("%d",&getdate.day);
}
if(getdate.year%4==0 && getdate.year%100!=0 && getdate.year%400==0)
{
printf("今年是闰年/n");
ch=countday(y,getdate);
printf("从%d年头开始已经过去%d天了哦",getdate.year,ch);
}
else
{
y[1]=28;
printf("今年是平年/n");
ch=countday(y,getdate);
printf("从%d年头开始 已经过去 %d天了",getdate.year,ch);
}
return 0;
}
int countday(const int *n,struct date m)
{
int i;
for(i=0;i<m.month;i++)
total+=n[i];
total=total+m.day;
return total;
}
编译环境:VC6.0,XP
- C语言练习笔记:计算日期程序编写
- C语言练习之程序编写
- C语言 日期计算
- 用C语言编写一个计算薪水的程序
- C语言程序练习
- c语言程序练习
- C语言程序编写
- C语言程序编写
- C程序设计语言练习1-23 编写一个删除C语言程序中所有的注释语句
- c语言小程序练习
- c语言程序练习一
- c语言程序练习二
- C语言程序练习三
- C语言编写时钟程序
- C语言编写五子棋程序
- C语言编写CGI程序
- C语言编写GUI程序
- C语言编写程序计时
- Symbian 命令行编译程序
- 一个人的战斗
- 按键精灵
- openGL的局限
- C# 数据库连接字符串集合
- C语言练习笔记:计算日期程序编写
- 每日IN语(2009-01-23)世界上永远不可调和的两种矛盾
- 老紫竹给大家拜早年了,祝大家春节快乐,全家身体健康
- 网页防盗代码
- 09年我要开始我的blog啦
- 开始
- 【转】对GIS的一些冷思考
- ASCII码表
- 我的头像