| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 874 人关注过本帖
标题:[求助]报错2个
只看楼主 加入收藏
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
 问题点数:0 回复次数:12 
[求助]报错2个

#include<stdio.h>
void week_several(void);
void dates(void);
void Is_leapyear(int year);
main()
{ int num;
printf(" MENU");
printf("1.Inquires some year, month and day is the week several\n");
printf("2.Inquires some year whether is the leap year\n");
printf("3.Prints some year the whole year calendar\n");
printf("4.Exit\n");
printf("Please choose a number:");
scanf("%d",&num);
switch(num)
{case 1: dates();break;
case 2: break;
case 3:
case 4: break;
default: printf("Your input is not correct, please choose again");
}
/*主函数*/


void dates(void)
{int year,month,day,week_several;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
prinf("the date you inquire is:%s",week_several(year,month,day));
}
/*查询星期几的主函数*/


void week_several(long year,long month,long day)
{int i,j,k,week_day,days=0;
for(i=1900;i<year;i++)
{if(Is_leapyear(i)) days+=366;
else days+=365;
}
/*计算年份天数*/
for(j=1;j<month;j++)
{switch(j)
{case 2:if(Is_leapyear(year)) days+=29;
else days+=28; break;
case 4: case 6: case 9: case 11: days+=30; break;
default: days+=31; break;
}
}
/*计算月份天数*/
for(k=1;k<=day;k++)
days++;
/*计算总天数 */
week_day=days%7;
switch(week_day)
{case 1: return("Monday"); break;
case 2: return("Tuesday"); break;
case 3: return("Wednesday"); break;
case 4: return("Thusday"); break;
case 5: return("Friday"); break;
case 6: return("Saturday"); break;
case 0: return("Sunday"); break;
}
}

void Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0)}

程序没写完 但
里面两个报错 :
void dates(void)报错 expression syntax in function
最后一行报错 少了个}

帮忙哦

搜索更多相关主题的帖子: void calendar include several 
2007-06-01 17:52
小子也大叔
Rank: 2
等 级:新手上路
威 望:4
帖 子:143
专家分:0
注 册:2007-4-23
收藏
得分:0 
我就看了下你最后的代码 
void Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0)}  //这个地方你少了个; 

希望一心想学c的加我的群吧~~ 40834003
2007-06-01 17:55
phychyday
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-5-31
收藏
得分:0 
回复:(zhao9302)[求助]报错2个

#include<stdio.h>
void week_several(void);//后面写的函数带了3个参数,并且返回不可能是空
void dates(void);
void Is_leapyear(int year); //类型
main()
{ int num;
printf(" MENU");
printf("1.Inquires some year, month and day is the week several\n");
printf("2.Inquires some year whether is the leap year\n");
printf("3.Prints some year the whole year calendar\n");
printf("4.Exit\n");
printf("Please choose a number:");
scanf("%d",&num);
switch(num)
{case 1: dates();break;
case 2: break;
case 3:
case 4: break;
default: printf("Your input is not correct, please choose again");
}
/*主函数*/


void dates(void)
{int year,month,day,week_several;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
prinf("the date you inquire is:%s",week_several(year,month,day));//printf写错
}
/*查询星期几的主函数*/


void week_several(long year,long month,long day)//参数和上面输入的参数类型不同int ->long了
{int i,j,k,week_day,days=0;
for(i=1900;i<year;i++)
{if(Is_leapyear(i)) days+=366;
else days+=365;
}
/*计算年份天数*/
for(j=1;j<month;j++)
{switch(j)
{case 2:if(Is_leapyear(year)) days+=29;
else days+=28; break;
case 4: case 6: case 9: case 11: days+=30; break;
default: days+=31; break;
}
}
/*计算月份天数*/
for(k=1;k<=day;k++)
days++;
/*计算总天数 */
week_day=days%7;
switch(week_day)
{case 1: return("Monday"); break;
case 2: return("Tuesday"); break;
case 3: return("Wednesday"); break;
case 4: return("Thusday"); break;
case 5: return("Friday"); break;
case 6: return("Saturday"); break;
case 0: return("Sunday"); break;
}
}

void Is_leapyear(int year) /*判断闰年*/
//肯定要返回0或1进行上面的判断么
{return(year%4==0&&year%100!=0||year%400==0)}//少;

2007-06-01 20:40
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
得分:0 

我按楼上说的将错误改了下
但还是同样的报错
为什么呀 郁闷~~·

#include<stdio.h>
void week_several(int ,int ,int);
void dates(void);
void Is_leapyear(int year);
main()
{ int num;
printf(" MENU");
printf("1.Inquires some year, month and day is the week several\n");
printf("2.Inquires some year whether is the leap year\n");
printf("3.Prints some year the whole year calendar\n");
printf("4.Exit\n");
printf("Please choose a number:");
scanf("%d",&num);
switch(num)
{case 1: dates();break;
case 2: break;
case 3:
case 4: break;
default: printf("Your input is not correct, please choose again");
}
/*主函数*/


void dates(void)
{int year,month,day,week_several;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
printf("the date you inquire is:%s",week_several(year,month,day));
}
/*查询星期几的主函数*/


void week_several(int year,int month,int day)
{int i,j,k,week_day,days=0;
for(i=1900;i<year;i++)
{if(Is_leapyear(i)) days+=366;
else days+=365;
}
/*计算年份天数*/
for(j=1;j<month;j++)
{switch(j)
{case 2:if(Is_leapyear(year)) days+=29;
else days+=28; break;
case 4: case 6: case 9: case 11: days+=30; break;
default: days+=31; break;
}
}
/*计算月份天数*/
for(k=1;k<=day;k++)
days++;
/*计算总天数 */
week_day=days%7;
switch(week_day)
{case 1: return("Monday"); break;
case 2: return("Tuesday"); break;
case 3: return("Wednesday"); break;
case 4: return("Thusday"); break;
case 5: return("Friday"); break;
case 6: return("Saturday"); break;
case 0: return("Sunday"); break;
}
}

void Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0);}


我要一步一步往上爬……
2007-06-02 14:54
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
得分:0 

有没有大家HELP HELP 啊 ~ 没时间咯哦


我要一步一步往上爬……
2007-06-04 13:43
koolism
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2007-3-22
收藏
得分:0 


void Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0);}

void 你还return??!
建议把void 该为int 或者bool

void dates(void)//此处把函数定义括号里的void去掉
{int year,month,day,week_several;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
printf("the date you inquire is:%s",week_several(year,month,day));
}
/*查询星期几的主函数*/


不知道痛苦,不知道饥饿,不知道休息,只知道勇往无前...
2007-06-05 01:36
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
得分:0 

很郁闷 我再次修改以后还是报错两个
估计我得重写这个程序
可是写来写去还是这么想的~


我要一步一步往上爬……
2007-06-05 12:48
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
得分:0 

刚仔细再次修改了下
#include<stdio.h>
void week_several(int ,int ,int);
void dates();
int Is_leapyear(int);
main()
{int num;
printf(" MENU");
printf("1.Inquires some year, month and day is the week several\n");
printf("2.Inquires some year whether is the leap year\n");
printf("3.Prints some year the whole year calendar\n");
printf("4.Exit\n");
printf("Please choose a number:");
scanf("%d",&num);
switch(num)
{case 1: dates();break;
case 2: break;
case 3:
case 4: break;
default:printf("Your input is not correct, please choose again");
}
}
/*主函数*/


void dates()
{int year,month,day;
printf("Please give the date you want to inquire");
scanf("%d%d%d",&year,&month,&day);
printf("the date you inquire is:%s",week_several(year,month,day));
}
/*查询星期几的主函数*/


void week_several(int year,int month,int day)
{int i,j,k,week_day,days=0;
for(i=1900;i<year;i++)
{if(Is_leapyear(i)) days+=366;
else days+=365;
}
/*计算年份天数*/
for(j=1;j<month;j++)
{switch(j)
{case 2:if(Is_leapyear(year)) days+=29;
else days+=28; break;
case 4: case 6: case 9: case 11: days+=30; break;
default: days+=31; break;
}
}
/*计算月份天数*/
for(k=1;k<=day;k++)
days++;
/*计算总天数 */
week_day=days%7;
switch(week_day)
{case 1: return("Monday"); break;
case 2: return("Tuesday"); break;
case 3: return("Wednesday"); break;
case 4: return("Thusday"); break;
case 5: return("Friday"); break;
case 6: return("Saturday"); break;
case 0: return("Sunday"); break;
}
}

int Is_leapyear(int year) /*判断闰年*/
{return(year%4==0&&year%100!=0||year%400==0);}


现在程序这样了 又有了一个新的错误:
第29行 NOT an allowed type in fuction dates

那应该怎么改呢 我是新手很麻烦 见谅啊~


我要一步一步往上爬……
2007-06-05 14:08
死了都要C
Rank: 4
来 自:四川成都
等 级:贵宾
威 望:13
帖 子:1582
专家分:116
注 册:2006-12-7
收藏
得分:0 
看这句:printf("the date you inquire is:%s",week_several(year,month,day));

年是要把week_several以%S的方式输出吧``` `

但是你把week_several定义为void```也就是说``week_several是空类型的``没有任何值``

那么这个时候%S和week_several的类型就不匹配```


女施主``我给你``送茶来了```师太``你就从了老衲吧``
代码本天成~~~妙头偶得之```
2007-06-05 14:19
zhao9302
Rank: 1
等 级:新手上路
帖 子:170
专家分:0
注 册:2007-5-10
收藏
得分:0 

那我应该怎么改呢?


我要一步一步往上爬……
2007-06-05 14:19
快速回复:[求助]报错2个
数据加载中...
 
   



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

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