编写程序打印单月的日历,用户指定这个月的天数和该月起始日是星期几
void Printdata(int day, int wk)
{
if (day < 1 || day>31)
return;
if (wk < 0 || wk>6)
return;
int k = 0;
char str[] = { " " };
printf(" 日 1 2 3 4 5 6 \n");
for (int i = 0; i < wk; i++)
{
printf("%s", str);
k = k + 1;
}
for (int i = 1; i <= day; i++)
{
printf("%3d", i);
k = k + 1;
if (k % 7 == 0)
{
printf("\n");
}
}
printf("\n");
}
int main()
{
Printdata(31, 3);
return 0;
}