2 回答
TA贡献1843条经验 获得超7个赞
#define JANUARY 1
#define FEBRUARY 2
#define MARCH 3
#define APRIL 4
#define MAY 5
#define JUNE 6
#define JULY 7
#define AUDUST 8
#define SEPTEMBER 9
#define OCTOBER 10
#define NOVERBER 11
#define DECEMBER 12
#define MONTH 12
#define DATALENTH 2
int data[MONTH][DATALENTH];
void getData(void);
void output(void);
void main(void)
{
getData();
output();
getch();
}
void getData(void)
{
int tempMonth,tempData;
int i = 0;
int flag = 0;
while(!flag){
flag = scanf("%d %d",&tempMonth,&tempData);
getchar();/*清空缓存*/
if(!flag){/*输入为整型以外的数据*/
printf("DATA ERROR!");
// getchar();/*清空缓存*/
continue;
}
else{
data[i][0] = tempMonth;
data[i][1] = tempData;
//printf("%d %d\n",data[i][0],data[i][1]);
i++;
flag = 0;
}
/*结束输入*/
if( ( !tempMonth ) || ( !tempData ) ){
break;
}
}
}
void output(void)
{
int i = 0;
while(!data[i][0] && !data[i][1])
switch(data[i][0]){
case FEBRUARY:
if( 0 < data[i][1] < 30 ){
printf("YES\n");
}
else{
printf("NO\n");
}
break;
case JANUARY:
case MARCH:
case MAY:
case JULY:
case AUDUST:
case OCTOBER:
case DECEMBER:
if( 0 < data[i][1] < 32 ){
printf("YES\n");
}
else{
printf("NO\n");
}
break;
case APRIL:
case JUNE:
case SEPTEMBER:
case NOVERBER:
if( 0 < data[i][1] < 31 ){
printf("YES\n");
}
else{
printf("NO\n");
}
break;
default:
printf("NO\n");
break;
}
i++;
}
}
TA贡献1776条经验 获得超12个赞
int n m
if(n>o&&n<=10&&m>0&&m<=30){printf();}随便写了下,估计有很多错误的
好久没懂c了但是思路是这样的、选择语句
添加回答
举报