标签:har lease 数组 图片 arc 解题思路 lan mamicode clu
解题思路: 首先定义字符串指针数字,数组中每一个元素都存放一个字符串指针,每个指针指向不同字符串的位置。则输入月份数字后,根据下标获取对应月份字符串的地址即可
答案:
#include<stdio.h>
int main()
{
int month;
char* Month[12] = { "January","February","March","April","May","June",
"July","August","September","October","November","December" };
while (1) {
printf("Please enter the month: ");
scanf_s("%d", &month);
if (month < 1 && month>12) {
printf("Input error, Month should be greater than 0 and less than 12\n");
}
printf("%s\n", Month[month - 1]);
}
return 0;
}
编一程序,输入月份号,输出该月的英文月名。例如,输人3,则输出"March" ,要求用指针数组处理
标签:har lease 数组 图片 arc 解题思路 lan mamicode clu
原文地址:https://www.cnblogs.com/vs2019/p/13630974.html