A. c语言转换日期的表示形式
#include <stdio.h>
#include <string.h>
int main()
{int month,b,c;
scanf("%d/%d/%d",&month,&b,&c);
switch(month)
{
case 1:printf("Jan,%d,%d\n",b,c);
break;
case 2:printf("Feb,%d,%d\n",b,c);
break;
case 3:printf("Mar,%d,%d\n",b,c);
break;
case 4:printf("Apr,%d,%d\n",b,c);
break;
case 5:printf("May,%d,%d\n",b,c);
break;
case 6:printf("Jun,%d,%d\n",b,c);
break;
case 7:printf("Jul,%d,%d\n",b,c);
break;
case 8:printf("Aug,%d,%d\n",b,c);
break;
case 9:printf("Sep,%d,%d\n",b,c);
break;
case 10:printf("Oct,%d,%d\n",b,c);
break;
case 11:printf("Nov,%d,%d\n",b,c);
break;
case 12:printf("Dec,%d,%d\n",b,c);
break;
default:printf("Data Error\n");
}
return 0;
}
B. c语言:从键盘上输入数字形式的年月日,输出英文形式的年月日,并指出这天是星期几.
voidmain()
{
inty,m,d,a;
scanf("%d%d%d",&y,&m,&d);
if(m==1||m==2)
{
m+=12;
y--;
}
a=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7+1;//这是一个公式,网络下就知道了。
printf("输入的这一天是星期%d ",a);
}
C. C语言提问:将一个月份数字转换成月份的英文名称
#include<stdio.h>
void main()
{
int n;
char M;
do
{
printf("Please input the number of the month:\n");
scanf("%d",&n);
switch(n)
{
case 1:
printf("您输入的月份的英文名称是:January\n");
break;
case 2:
printf("您输入的月份的英文名称是:February\n");
break;
case 3:
printf("您输入的月份的英文名称是:March\n");
break;
case 4:
printf("您输入的月份的英文名称是:April\n");
break;
case 5:
printf("您输入的月份的英文名称是:May\n");
break;
case 6:
printf("您输入的月份的英文名称是:June\n");
break;
case 7:
printf("您输入的月份的英文名称是:July\n");
break;
case 8:
printf("您输入的月份的英文名称是:Augest\n");
break;
case 9:
printf("您输入的月份的英文名称是:September\n");
break;
case 10:
printf("您输入的月份的英文名称是:October\n");
break;
case 11:
printf("您输入的月份的英文名称是:November\n");
break;
case 12:
printf("您输入的月份的英文名称是:December\n");
break;
}
printf("Do you want to continue? Input Y or not\n");
scanf(" %c",&M);
}while(M=='Y');
}