#include <stdio.h> #include <conio.h>
int leap(int year) { if( (year%4==0&&year%100!=0)||(year%400==0) ) return 1; else return 0; }
int leftdays1(int year,int month,int day) { int i; int days=0; int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; for(i=month+1;i<=12;i++) { if(i==2&&leap(year)==1) days+=29; else days+=d[i]; } days+=(d[month]-day); return days; }
int leftdays2(int year,int month,int day) { int i; int days=0; int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; for(i=1;i<month;i++) { if(month>=3&&i==2&&leap(year)==1) days+=29; else days+=d[i]; } days+=day; return days; }
int main() { int b_year,b_month,b_day; int o_year,o_month,o_day; int totaldays; int i,a,b,c=0,m=0; int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; clrscr(); printf("please input the start date with space\n"); scanf("%d %d %d",&b_year,&b_month,&b_day); printf("please input the end date\n"); scanf("%d %d %d",&o_year,&o_month,&o_day); a=leftdays1(b_year,b_month,b_day); b=leftdays2(o_year,o_month,o_day);
for(i=1;i<(o_year-b_year);i++) c+=365+leap(b_year+i);
if(o_year>b_year) totaldays=a+b+c; else if(o_year==b_year&&o_month>b_month) { for(i=1;i<(o_month-b_month);i++) { if(i==2) m+=d[i]+leap(b_year); else m+=d[i]; } totaldays=m+d[b_month]-b_day+o_day; } else totaldays=o_day-b_day; printf("There are %d days left\n",totaldays); getch(); return 0; }
上面的程序本想在自已的机器上编译运行一下,可当我点编译时出现一个对话框写的是
compiler and linker output c:\DOCUME~1\USER\LOCALS~1\Temp\ccoVaaaa.o(.txt+0x2b3):time.c undefined reference to 'clrscr'
是那里出了问题呢?我用的编译软件是Dev--C++请教是那里出了问题?????