这是输入数据时的样子
我已完成第一部分以输入数据
#include <stdio.h>
int a, b, c, weekday, i, day, month;
int main() {
printf("Number of days in the month: ");
scanf("%d", &a);
while(true){
if((a <= 31) && (a >= 28)){
break;
} else {
printf("invalid data try again :");
scanf("%d", &a);
}
}
printf("Code for the starting day:");
scanf("%d", &b);
printf("\nMo Tu We Th Fr Sa So\n");
}
我已经使用redone第一部分进行了更新,以确保数据有效并且printf用于标题
答案 0 :(得分:0)
试试这个
printf("\nMo Tu We Th Fr Sa Su\n" );
if(weekday < 7)
for(i=0; i<weekday; i++)
printf(" " );
for ( day = 1; day <= days_in_month[month]; day++ )
{
printf("%02d", day );
if ( ( day + weekday) % 7 > 0 ){
printf(" " );
}
else{
printf("\n " );
}
}