| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 438 人关注过本帖
标题:哪里出问题了??
只看楼主 加入收藏
linxwu
Rank: 1
等 级:新手上路
帖 子:21
专家分:2
注 册:2014-2-28
结帖率:25%
收藏
 问题点数:0 回复次数:6 
哪里出问题了??
#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
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
哪里有问题  有什么问题???

DO IT YOURSELF !
2014-03-21 11:41
linxwu
Rank: 1
等 级:新手上路
帖 子:21
专家分:2
注 册:2014-2-28
收藏
得分:0 
回复 3楼 wp231957
编译错误
2014-03-21 13:15
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
我没有编程环境

你把错误信息发出来

DO IT YOURSELF !
2014-03-21 14:48
TAAAAB
Rank: 7Rank: 7Rank: 7
来 自:湖南
等 级:黑侠
威 望:1
帖 子:243
专家分:635
注 册:2011-5-29
收藏
得分:0 
编译是没有错的,只是红色部分的位放错了

程序代码:
#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);
                }
                printf("%d\n",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);
                } 
                printf("%d\n",day_count);
            }
            
        }
        else
            printf("Wrong Input");
    }
    
    return 0;

 } 

人有多懒,编程就有多难。
2014-03-21 23:20
TAAAAB
Rank: 7Rank: 7Rank: 7
来 自:湖南
等 级:黑侠
威 望:1
帖 子:243
专家分:635
注 册:2011-5-29
收藏
得分:0 
编译是没有错的,只是红色部分的位放错了

程序代码:
#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);
                }
                printf("%d\n",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);
                } 
                printf("%d\n",day_count);
            }
            
        }
        else
            printf("Wrong Input");
    }
    
    return 0;

 } 

人有多懒,编程就有多难。
2014-03-21 23:20
快速回复:哪里出问题了??
数据加载中...
 
   



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

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