例64:C语言编写一个程序,输入月份号,输出该月的英文月名。例如,输入「3」,则输出「March」,要求用指针数组处理。 解题思路:读者看着道题的时候,需要注意一点,数组是从0开始往依次加的。 C语言源代码演示: #include<stdio.h>//头文件 int main()//主函数 { char *month_name[13]={"illegal month","...
例:输入"3",则输出"March",用指针数组处理。define _CRT_SECURE_NO_WARNINGS include<stdio.h> include<stdlib.h> void main() { int month;char* Month[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" };...
"September","October","November","December"};//定义指针数组 int number;//定义整型变量 printf("输入月份:");//提示语句 scanf("%d",&number);//键盘输入 if((number<=12)&&(number>=1))//判断条件 { printf("%d",number);//提示语句 printf("月的英文是%s\n",*(month_name+number)); } e...
include "stdio.h"int main(int argv,char *argc[]){char m[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"},x;printf("Enter a month:\nx=");if(scanf("%d",&x)!=1 || x<1 || x>12)...
例79:C语言编写一个程序,输入月份号,输出该月的英文月名。例如,输入「3」,则输出「March」,要求用指针数组处理。 解题思路:读者看着道题的时候,需要注意一点,数组是从0开始往依次加的。 C语言源代码演示: 代码语言:javascript 复制 #include<stdio.h>//头文件intmain()//主函数{char*month_name[13]={"ill...
这段代码就是单纯的将月份英文名称保存在指针数组(每个指针元素指向一个字符串首地址)。然后通过输入的数字找到对应的数组元素。这里前面初始化数组、输入这里都没什么说。关键是打印printf那里,本来numbers--;之后直接使用printf("%s",months[numbers])就可以取到对应英文名字。但这里代码特地用数组名+...
void PrinMonth(int *month);int main(){ int mon;scanf("%d",&mon);PrinMonth(&mon);return 0;} void PrinMonth(int *month){ char emonth[][12]={"January","February","March","April","May","June","July","August","September","October","November","December"};printf("%s...
int main(){ int month;printf("请输入月份号(1-12):\n")scanf("%d",month);switch(month){ case 1:printf("January");break;case 2:printf("February");break;case 3:printf("March");break;case 4:printf("April");break;case 5:printf("May");break;case 6:printf("June");break...
如下代码可以解决:#include<stdio.h>int main(){ char* month[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; int i; scanf("%d",&i); printf("%s\n",month[i-1]); return 0;} ...
功能:输入月份号并输出英文月份名描述:使用指针数组创建一个含有月份英文名的字符串数组并使用指向指针的指针指向这个字符串数组,实现输出数组中的指定字符串 2 思路 使用指针的指针实现对字符串数组中的字符串的输出 *month[] 属于指针数组,*month本身就是指针,数组中都是存放着指针。那么 month是指针数组的首地址,...