| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 344 人关注过本帖
标题:c语言问题
取消只看楼主 加入收藏
mkl34367803
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-9-6
结帖率:20%
收藏
已结贴  问题点数:10 回复次数:1 
c语言问题
我自己写的一个计算一年中某一天在该年是第几天:
#include<stdio.h>
void main()
{
    int y,m,d,total=0;
    printf("please input y空格m空格d:");
    scanf("y/m/d=%d%d%d",&y,&m,&d);
    if(m==1)
        printf("total=%d",d);

    if(m==2)
        printf("total=%d",d+31);

    if(m==3)
    {
        if(y%4==0&&(y%100!=0)||y%400==0)
            printf("total=%d",d+31+29);
        else
            printf("total=%d",d+31+28);
    }

        if(m==4)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31);
        else
            printf("total=%d",d+31+28+31);
    }

        if(m==5)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30);
        else
            printf("total=%d",d+31+28+31+30);
    }

        if(m==6)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31);
        else
            printf("total=%d",d+31+28+31+30+31);
    }

        if(m==7)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30);
        else
            printf("total=%d",d+31+28+31+30+31+30);
    }

        if(m==8)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30+31);
        else
            printf("total=%d",d+31+28+31+30+31+30+31);
    }

        if(m==9)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30+31+31);
        else
            printf("total=%d",d+31+28+31+30+31+30+31+31);
    }

        if(m==10)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30+31+31+30);
        else
            printf("total=%d",d+31+28+31+30+31+30+31+31+30);
    }

        if(m==11)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30+31+31+30+31);
        else
            printf("total=%d",d+31+28+31+30+31+30+31+31+30+31);
    }

        if(m==12)
    {
        if(y%4==0&&y%100!=0||y%400==0)
            printf("total=%d",d+31+29+31+30+31+30+31+31+30+31+30);
        else
            printf("total=%d",d+31+28+31+30+31+30+31+31+30+31+30);
    }

}
搜索更多相关主题的帖子: please c语言 include total 
2012-09-06 21:42
mkl34367803
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2012-9-6
收藏
得分:0 
运行不起啊
2012-09-07 22:45
快速回复:c语言问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012631 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved