#include
int main()
{
char*month_name[13]={"illegal month","January","February","March","April",
"May","June","July","August","September","October","November","December"};
int n;
printf("input month:\n");
scanf("%d",&n);
if((n<=12)&&(n>=1))
{
printf("it is %s.\n",*(month_name+n));
}
else
{
printf("it is wrong.\n");
}
return 0;
}
扩展资料:
在计算机系统中,一条机器指令规定了计算机系统的一个特定动作。一个系列的计算机在硬件设计制造时就用了若干指令规定了该系列计算机能够进行的基本操作,这些指令一起构成了该系列计算机的指令系统。
在计算机应用的初期,程序员使用机器的指令系统来编写计算机应用程序,这种程序称为机器语言程序。使用机器语言编写的程序,由于每条指令都对应计算机一个特定的基本动作,所以程序占用内存少、执行效率高。
缺点也很明显,如:编程工作量大,容易出错;依赖具体的计算机体系,因而程序的通用性、移植性都很差。
提示你一下吧 具体的就不帮你编了 程序这个东西要多编才会熟练的 用switch语句就可以实现这个功能了 至于细节部分 自己考虑吧 还有注意 英文月份名是字符串 就提醒这么多了
为了节省时间,我用简写吧
#include
#include
#define N 12
static const char *g_EngMon[N] =
{
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Dec",
"Nov",
"Dec",
};
void main()
{
char month[20];
int status = 0;
memset(month, 0x0, sizeof(month));
do
{
printf("please input english month:\n");
scanf("%s", month);
for(int i = 0; i < N; i++)
{
status = stricmp(month, g_EngMon[i]);
if( status == 0)
{
printf("Month: %d\n", i+1);
}
}
fflush(stdin);
}while(1);
}
我用C++的。
#include
#include
using namespace std;
int main()
{
string month;
while(cin>>month)
{
switch(month)
{
case January:cout<<1<
}
return 0;
}
用什么语言啊!?