C语言编写一个程序,显示单月日历,一个月的天数由用户设定

2024-11-13 03:43:47
推荐回答(3个)
回答(1):

#include弯扮兆
void main()
{
int days,start;
printf("Enter the days:"埋租);
scanf("%d",&days);
printf("Enter the starting day:");
scanf("缺镇%d",&start);

for(int i=2-start;i<=days;i++)
{
if(i<=0)
printf(" ");
else
{printf("%5d",i);}
if((i+start-1)%7==0)
printf("\n");
}
printf("\n");
}

回答(2):

#include
#include

void main(void)
{
int days;
int str_week;
int i;

printf("Enter number of days in month:");
scanf("%d"穗老神,&days);

printf("猜亏Enter starting day of the week in (1=Sun,7=Sat):");
scanf("%d",&str_week);

for(i=1;i<=days;i++)
{
if(i%7==(2+(7-str_week)))
printf("\t\n");

printf("%2d ",i);
}
}
但是第一行有问题。。含睁

回答(3):

不是很难