| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 461 人关注过本帖
标题:大家帮我修改一下这个程序的错误咯在线等,立结!
只看楼主 加入收藏
monima15
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-2-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:8 
大家帮我修改一下这个程序的错误咯在线等,立结!
#include<stdio.h>
#include<stdlib.h> /*定义头文件*/
int runnian(int year)/*定义变量*/
{
    if(year%4==0&&year%100!=0||year%400==0) /*利用函数判断输入年份是闰年还是平年*/
        return 1;
    else
        return 0;
}
int day1(int year,int month)
{
    int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};/*定义数组确定12个月每个月的天数*/
    if(runnian(year)) /*如果输入年份是闰年*/
        a[1]=29;/*二月29天*/
    return a[month-1];
}
int day2(int year,int month,int day),
int i,sum=0;
for(i=1;i<month;i++)
{
    sum+=day1(year,i);
}
sum+=day;
return sum;
}
int week1(int year,int month,int day)
{
    int number=(year-1)+(year-1)/4-(year-1)/100+(year-1)/400+day2(year,month,day);
    number%=7;
    return number;
}
char *Week2(int number)
{
    switch(number)/*分类一周七天*/
    {
        case 0:
            return "星期日";
            case 1:
                return "星期一";
                case 2:
                    return "星期二";
                    case 3:
                        return "星期三";
                        case 4:
                            return "星期四";
                            case 5:
                                return "星期五";
                                case 6:
                                    return "星期六";
                                    default:
                                        return "错误!请您重新输入。";/*不符和上面七种情况的报错提示*/
    }
}
void x1(int year,int month,int day)
{
    int number=week1(year,month,day);
    if(runnian(year))printf("闰年");/*年份为闰年则输出"闰年"*/
    else printf("平年");
    printf(" %d 年  %d 月 %d 日%10s\n\n",year,month,day,Week2(number));/*按年 月 日输出结果*/
}
void x2(int year,int month)
{
    int max,number,i,j=1;
    max=day1(year,month);
    number=week1(year,month,1);
    printf("%2s%2s%2s%2s%2s%2s%2s\n"," 星期日 "," 星期一 "," 星期二"," 星期三 "," 星期四 "," 星期五 "," 星期六 ");/*按照间隔打印日历
    for(i=0;i<number;i++)
    {
        printf("        ");
    }
    while(j<=max)
    {
        printf("%8d",j);
        if(i%7==6)
        {
            printf("\n");
        }
        i++;
        j++;
    }
    printf("\n\n");
}
int x3(int year,int month,int day)
{
    if(year<0||month<1||month>12||day<1||day>day1(year,month))/*当输入植出现这些情况时*/
        return 0;/*返回0*/
    else
        return 1;/*返回1*/
}
void nianli(int year)
{
    int i;
    printf("\n");
    for(i=1;i<=12;i++)
    {
        if(runnian(year))printf("闰年");
        else printf("平年");
        printf(" %d 年 %d 月\n\n",year,i);
    }
}
void yueli(int year,int month)
{
    if(runnian(year))
        printf("闰年");
    else printf("平年");
    printf(" %d 年 %d 月\n\n",year,month);
    x2(year,month);
}
void rili(int year,int month,int day)
{
    printf("\n");
    x1(year,month,day);
}
void main()
{
    int year,month,day,a,b;
    while(1)
    {
        printf("\n\n\n\n");
        printf("             **********************************************************\n\n");
        printf("                             *                        *                   \n");
        printf("                               欢迎进入万年历查询系统                   \n");
        printf("                             *                        *                  \n\n");
        printf("             **********************************************************\n\n\n");
        printf("                  1 年历 2 月历 3 日历 4 退出\n");
        printf("                  请输入您的选择<1~4>,按回车键确定: ");
        scanf("%d",&b);
        switch(b)
        {
            case 1:/*选择1时*/
                printf("\n请输入您要查的年份: ");/*给出输入提示*/
                scanf("%d",&year);/*输入查询的年份*/
                a=x3(year,1,1);
                if(a==0)
                {
                    printf("错误!请您重新输入。\n");/*输入植异常时报错*/
                    break;
                }
                nianli(year);
                break;
                case 2:/*选择二时*/
                    printf("\n请输入您要查的年和月,年月之间用空格隔开: ");/*给出输入提示*/
                    scanf("%d%d",&year,&month);/*输入需要查询的年 月*/
                    a=x3(year,month,1);
                    if(a==0)
                    {
                        printf("错误!请您重新输入。\n");
                        break;
                    }
                    yueli(year,month);
                    break;
                    case 3:/*选择3时*/
                        printf("\n请输入您要查的年月日,年月日之间用空格隔开: ");/*给出输入提示*/
                        scanf("%d%d%d",&year,&month,&day);/*输入年 月 日*/
                        a=x3(year,month,day);
                        if(a==0)
                        {
                            printf("错误!请您重新输入。\n");/*输入植异常时报错*/
                            break;
                        }
                        rili(year,month,day);
                        break;
                        case 4:
                            exit(0);
                            default:
                                printf("错误!请您重新输入。\n\n");
                                }
    }
}





--------------------Configuration: cnc - Win32 Debug--------------------
Compiling...
cnc.c
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(18) : error C2059: syntax error : 'type'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2059: syntax error : 'for'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2143: syntax error : missing '{' before '<'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2059: syntax error : '<'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2143: syntax error : missing '{' before '++'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2059: syntax error : '++'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(19) : error C2059: syntax error : ')'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(23) : error C2143: syntax error : missing '{' before '+='
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(23) : error C2059: syntax error : '+='
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(24) : error C2059: syntax error : 'return'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(25) : error C2059: syntax error : '}'
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(56) : warning C4013: 'week1' undefined; assuming extern returning int
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(87) : error C2181: illegal else without matching if
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(88) : warning C4098: 'x2' : 'void' function returning a value
C:\Documents and Settings\joaquin\My Documents\c\cnc.c(133) : warning C4013: 'x3' undefined; assuming extern returning int
执行 cl.exe 时出错.

cnc.obj - 1 error(s), 0 warning(s)

[ 本帖最后由 monima15 于 2013-2-28 21:15 编辑 ]
搜索更多相关主题的帖子: include return 在线 
2013-02-28 20:59
monima15
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-2-28
收藏
得分:0 
求解啊!  各位大神们。。
2013-02-28 21:04
monima15
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-2-28
收藏
得分:0 
难道没人在吗
2013-02-28 21:09
逆风而前
Rank: 7Rank: 7Rank: 7
来 自:福建
等 级:黑侠
威 望:7
帖 子:193
专家分:567
注 册:2013-2-14
收藏
得分:4 
星期五 "," 星期六 ");/*按照间隔打印日历*/
掉了红色的“*/”部分
2013-02-28 21:54
逆风而前
Rank: 7Rank: 7Rank: 7
来 自:福建
等 级:黑侠
威 望:7
帖 子:193
专家分:567
注 册:2013-2-14
收藏
得分:0 
int day2(int year,int month,int day)
{  此处掉了“{”
int i,sum=0;
for(i=1;i<month;i++)
{
    sum+=day1(year,i);
}
sum+=day;
return sum;
}
2013-02-28 21:55
breaker_d
Rank: 1
等 级:新手上路
帖 子:7
专家分:4
注 册:2013-2-23
收藏
得分:4 
看着都晕~~~~~
2013-02-28 22:24
小xiong
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:388
专家分:1722
注 册:2013-2-8
收藏
得分:4 
好长啊,晕
2013-02-28 22:26
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:4 
注意代码风格。。。


[fly]存在即是合理[/fly]
2013-02-28 22:35
wsws23
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:105
专家分:107
注 册:2012-3-13
收藏
得分:4 
错误:1./*按照间隔打印日历*/ 少了*/
      2.int day2(int year,int month,int day),/这里不应该是','而应该是‘}’
        int i,sum=0;
        for(i=1;i<month;i++)
        {        
        sum+=day1(year,i);
            }
        sum+=day;
        return sum;
         }
2013-02-28 23:23
快速回复:大家帮我修改一下这个程序的错误咯在线等,立结!
数据加载中...
 
   



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

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