| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 438 人关注过本帖
标题:哪里出问题了??
取消只看楼主 加入收藏
linxwu
Rank: 1
等 级:新手上路
帖 子:21
专家分:2
注 册:2014-2-28
结帖率:25%
收藏
 问题点数:0 回复次数:2 
哪里出问题了??
#include <stdio.h>
int main()
{
    int i,line,year[10],month[10],day[10];
    scanf("%d",&line);
    for(i = 0;i < line;i++)
    {
            scanf("%d%d%d",&year[i],&month[i],&day[i]);
    }
    int j;
    for(j = 0;j < line;j++)
    {
        if(year[j]<=9999 && year[j]>=1 && month[j]<=12 && month[j]>=1)
        {
            if(year[j]%4==0&&year[j]%100!=0||year[j]%400==0)//判断闰年
            {
                int m,day_count = day[i];
                for(m=1;m<month[i];m++)
                {
                      switch (m)
                      {
                          case 1:case 3:case 5:case 7:case 8:case 10:case 12:
                              if(day[i]>=1&&day[i]<=31)
                              {
                                  day_count += 31;
                              }
                              
                              else
                              {
                                  printf("Wrong Input");   
                              }
                        break;
                          
                        case 4:case 6:case 9:case 11:   
                            if(day[i]>=1&&day[i]<=30)
                              {
                                  day_count += 30;
                              }
                          
                              else
                              {
                                  printf("Wrong Input");   
                              }
                        break;
                          case 2:
                             if(day[i]>=1&&day[i]<=29)
                              {
                                  day_count += 29;
                              }
                              
                              else
                              {
                                  printf("Wrong Input");   
                              }
                         break;
                      }
                      printf("%d",day_count);
                }
            }
            else
            {
               
                int m,day_count = day[j];
                for(m=1;m<month[j];m++)
                {
                      switch (m)
                      {
                          case 1:case 3:case 5:case 7:case 8:case 10:case 12:
                              if(day[j]>=1&&day[j]<=31)
                              {
                                  day_count += 31;
                              }
                              else
                              {
                                  printf("Wrong Input");   
                              }
                          break;
                        case 4:case 6:case 9:case 11:   
                            if(day[j]>=1&&day[j]<=30)
                              {
                                  day_count += 30;
                              }   
                              else
                              {
                                  printf("Wrong Input");   
                              }
                        break;                          
                          case 2:
                             if(day[j]>=1&&day[j]<=29)
                              {
                                  day_count += 28;
                              }
                              else
                              {
                                  printf("Wrong Input");   
                              }
                        break;                              
                      }
                  printf("%d",day_count);
                }   
            }
            
        }
        else
            printf("Wrong Input");
    }
        
    return 0;
}
搜索更多相关主题的帖子: include 
2014-03-21 11:31
linxwu
Rank: 1
等 级:新手上路
帖 子:21
专家分:2
注 册:2014-2-28
收藏
得分:0 
题目
输入年 月 日,判断所输入的日期是当年的第几天其中,输入的每个数据都在1--9999之间,允许参与运算的年份是1-9999间

输入
第一行输入数据个数以下每一行输入一组年月日,中间用空格隔开

输出
每行输出一个整数如果某行输入有误,则对应输出“Wrong Input”

样例输入
3
2014 1 1
1995 12 30
100 13 50

样例输出
1
364
Wrong Input



2014-03-21 11:32
linxwu
Rank: 1
等 级:新手上路
帖 子:21
专家分:2
注 册:2014-2-28
收藏
得分:0 
回复 3楼 wp231957
编译错误
2014-03-21 13:15
快速回复:哪里出问题了??
数据加载中...
 
   



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

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