用C语言编程,要完整的源代码;谢谢!

2024-12-01 06:53:57
推荐回答(4个)
回答1:

/*万年历*/
#include
#include

int isLeap(int year) //判断闰年
{
if(year%4!=0)
{
return 0;
}
else if(year%100!=0)
{
return 1;
}
else if(year%400!=0)
{
return 0;
}
else
{
return 1;
}
}

int GetMonthDays(int year,int month)//判断天数
{
switch(month){
case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31;break;
case 4:case 6:case 9:case 11:return 30;break;
case 2:if(isLeap(year)==1)
{
return 29;
}
else
{
return 28;
};break;
default:return 0;
}
}

int GetWeekDay(int year,int month,int day)//判断days天是星期几
{
int days;//总天数
int i=1;//计月份
int weekday;
days=(year-1)*365+(year-1)/4+(year-1)/400-(year-1)/100;
while(i {
days+=GetMonthDays(year,i);
i++;
}
days+=day;
weekday=days%7;
return weekday;
}

void PrintMonthCalender(int startDay,int days)//输出日历
{
int m=0;//计数空
int n=1;//计日期
while(m {
printf(" ");
m++;
}
while(n<=days)
{
printf("%d ",n);
if((n+m)%7==0)
{
printf("\n");
}
n++;
}
}

main()
{
int year,month,startDay,days;
printf("Please input year and month:");
scanf("%d %d",&year,&month);

startDay=GetWeekDay(year,month,1)%7;
days=GetMonthDays(year,month);//取得起始天和天数

printf("The result is:\n %d-%d\nSun. Mon. Tue. Wed. Thu. Fri. Sat.\n",year,month);
PrintMonthCalender(startDay,days);
system("pause");
return 0;
}

哇咔咔。。终于找到了,我们上个月的作业,哦哦呵呵。。。给我分吧

回答2:

#include #include #include #define X " Sun Mon Tue Wed Thu Fri Sat" void menu() { system("cls"); printf("\nTHIS IS THE MENU OF THE PROGRAM !"); printf("\nYOU CAN CHOOSE THE NUMBER FOR THE FUNCTIOM:"); printf("\n\n"); printf("1 Find the day by year-month-date.\n"); printf("2 Find the year you input if the leap year.\n"); printf("3 Print the calendar of the year you input.\n"); printf("4 Exit.\n\n"); printf("Input your choice:"); } int getday(int year,int month,int date) { int flag,s,i; int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int cont=0; flag=isleap(year); if(flag==1) a[2]++; for(i=1;i

回答3:

这个用C语言太困难啦,用VC++ 的ActiveX技术,和容易实现。

回答4:

是不是在视频里面加上标题之类的文字的题目?如果是的话,用会声会影做不就行了?