| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 418 人关注过本帖
标题:编译时没错,为什么一建立就错了呢?代码如下:
取消只看楼主 加入收藏
懒人打老虎
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-4-22
收藏
 问题点数:0 回复次数:0 
编译时没错,为什么一建立就错了呢?代码如下:
#include<stdio.h>
mian()
{
    int year,month,day,sum;
    printf("Please enter a date:");
    scanf("%d,%d,%d",&year,&month,&day);
    if((year%4==0&&year%100!=0)||year%400==0)
    {
        printf("This year is a leap yaer.\n");
        switch(month)
        {
        case 1:sum=day;
            break;
        case 2:sum=day+31;
            break;
        case 3:sum=day+31+29;
            break;
        case 4:sum=day+31+29+30;
            break;
        case 5:sum=day+31+29+30+31;
            break;
        case 6:sum=day+31+29+30+31+30;
            break;
        case 7:sum=day+31+29+30+31+30+31;
            break;
        case 8:sum=day+31+29+30+31+30+31+31;
            break;
        case 9:sum=day+31+29+30+31+30+31+31+30;
            break;
        case 10:sum=day+31+29+30+31+30+31+31+30+31;
            break;
        case 11:sum=day+31+29+30+31+30+31+31+30+31+30;
            break;
        case 12:sum=day+31+29+30+31+30+31+31+30+31+30+31;
            break;
        default:sum=-1;
        }
        if(sum=-1)
            printf("Data error!\n");
        else
        printf("Today is %d days of this year!\n",sum);
    }
    else
    {
        printf("This year is a nonleap year.\n");
        switch(month)
        {
        case 1:sum=day;
            break;
        case 2:sum=day+31;
            break;
        case 3:sum=day+31+28;
            break;
        case 4:sum=day+31+28+30;
            break;
        case 5:sum=day+31+28+30+31;
            break;
        case 6:sum=day+31+28+30+31+30;
            break;
        case 7:sum=day+31+28+30+31+30+31;
            break;
        case 8:sum=day+31+28+30+31+30+31+31;
            break;
        case 9:sum=day+31+28+30+31+30+31+31+30;
            break;
        case 10:sum=day+31+28+30+31+30+31+31+30+31;
            break;
        case 11:sum=day+31+28+30+31+30+31+31+30+31+30;
            break;
        case 12:sum=day+31+28+30+31+30+31+31+30+31+30+31;
            break;
        default:sum=-1;
        }
        printf("Today is %d days of this year!\n",sum);
    }
}
搜索更多相关主题的帖子: include 
2013-04-22 18:24
快速回复:编译时没错,为什么一建立就错了呢?代码如下:
数据加载中...
 
   



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

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