| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1180 人关注过本帖
标题:怎么会syntax error : missing ';' before 'type'呢
只看楼主 加入收藏
mgzcun
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-11-17
结帖率:100%
收藏
 问题点数:0 回复次数:1 
怎么会syntax error : missing ';' before 'type'呢
各位高手,小弟初学c语言,程序调了一下午,还是不知道错在哪,老是syntax error : missing ';' before 'type',还请大家帮忙!
还有希望高手说下导致syntax error : missing ';' before 'type'的常见原因;
#include<stdio.h>
#include <stdlib.h>

int search(int year,int month,int day)
{
    int pr(int year);
    int sum;
    int sum1;
    int sum2;
    int i;
    int count1=0;
    int count2=0;
    int a[4]={0};
    enum week{sun=0,mon,tue,wed,thu,fri,sta};
    enum week weekday;
    if(year<2010)
    {
        for(i=year+1;i<2010;i++)
            if(pr(year))
                count1++;
            else
                count2++;
        sum1=366*count1+365*count2;
        for(i=12;i>=month;i--)
        {
            switch(i)
             {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:a[0]++;break;

                case 4:
                case 6:
                case 9:
                case 11:a[1]++;break;

                case 2:
                    if(pr(year))
                    {
                        a[2]++;
                        break;
                    }
                    else
                    {
                        a[3]++;
                        break;
                    }
            }
        }
        sum2=a[0]*31+a[1]*30+a[2]*29+a[3]*28;
        sum=sum1+sum2-day+1;
    }
    else
    {
        for(i=2010;i<year;i++)
            if(pr(year))
                count1++;
            else
                 count2++;
        sum1=366*count1+365*count2;
         for(i=1;i<month;i++)
        {
            switch(i)
             {
             case 1:
             case 3:
             case 5:
             case 7:
             case 8:
             case 10:
             case 12:a[0]++;
                 break;
             case 4:
             case 6:
             case 9:
             case 11:a[1]++;
                 break;
             case 2:
                 if(pr(year))
                 {
                    a[2]++;break;
                 }
                 else
                 {
                     a[3]++;break;
                 }
         }
         sum2=a[0]*31+a[1]*30+a[2]*29+a[3]*28;
         sum=sum1+sum2+day;
    }
    return sum%7;
}


int main()
{
    int search(int year,int month,int day);
    int year,month,day;
    int n,q;

    printf("请输入您所具体到的年份:");
    scanf("%d %d %d",&year,&month,&day);
    n = 0;
    if(search(year,month,day))
        n = search(year,month,day);
    if(year<2010)
    {
        if(n+2>7)
            q=12-n;
        else
             q=5-n;
    }
     else
    {
        if(n+5>7)
             q=n-2-1;
        else
             q=n+5;
     }
    weekday=(enum week)q;
    printf("这个日期是:");
    switch(weekday)
     {
    case sun:printf("Sunday");
        break;
    case mon:printf("Monday");
        break;
    case tue:printf("Tuesday");
        break;
    case wed:printf("Wednesday");
        break;
    case thu:printf("Thursday");
        break;
    case fri:printf("Friday");
        break;
    case sta:printf("Saturday");
        break;
    }
 
    return 0;
}


int pr(int year)
{
    int leap=0;
    if(year%4==0&&year%100!=0||year%400==0)
    leap=1;
    return leap;
}
真诚请教,在线等待,谢!
搜索更多相关主题的帖子: syntax missing type 
2010-05-25 22:50
mgzcun
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-11-17
收藏
得分:0 
还有mian()中出现n,q未声明错误,可是我明明定义了啊!
2010-05-25 23:00
快速回复:怎么会syntax error : missing ';' before 'type'呢
数据加载中...
 
   



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

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