xiaoxaio..
2021-02-22 15:22
采纳率: 78.9%
浏览 180

本题要求实现函数,可以返回一个给定月份的英文名称,为什么这样写不行呢

#include <stdio.h>

char *getmonth( int n );

int main()

{

int n; char *s;

scanf("%d", &n);

s = getmonth(n);

if ( s==NULL )

printf("wrong input!\n");

else printf("%s\n", s);

return 0;

}

这个是我写的

char *getmonth( int n )
{

char a[][10]={"ee","January","February","March","April","May","June","July","August","September","October","November","December"};
 if(n<1||n>12) return NULL;
return a[n];
}

 

2条回答 默认 最新

相关推荐 更多相似问题