请各位高手帮忙看一下,哪里错了
这几天学到了结构体,写了代码,但是出错,请各位给我看看:程序代码:
#include <stdio.h> #include <string.h> struct data { int year,day; int month[12]={31,28,31,30,31,30,31,31,30,31,30,31}; }find; void yearmonthday() { int sum,i,j; printf("please input the year month and day:\n"); scanf("%d %d %d",&find.year,&i,&find.day); if(find.year%4==0&&find.year%100==0||find.year%400==0) {find.month[1]=29;} for(j=0;j<i;j++) { sum=sum+find.month[j]; } sum=sum+find.day; printf("the day is %d",sum); } void yearday() { int i,sum=0;int month1,day1; printf("please input the year and day:\n"); scanf("%d %d",&find.year,&find.day); if(find.year%4==0&&find.year%100==0||find.year%400==0) {find.month[1]=29;} month1=find.day/30; day1=find.day%30; printf("month=%d,day=%d",month1,day1); } void main() { int switches; printf("please input the case:\n"); printf("1.please input the year,day,give your month day.\n"); printf("2.please input the year month day give your data.\n"); printf("plase chose (1\2):\n"); scanf("%d",&switches); switch(swithes) { case 1:yearday();break; case 2:yearmonthday();break; default:printf("error!\n");break;break; } }
第一个函数是:给定年、月、日,求天数。
第二个函数是:给定年和天数求日月,第二个函数也不会写。
各位高手帮帮忙啊!