有一段代码:
#include
#include
void main()
{
char a,x;
static int b[255],c[255],i,k;
FILE *y;
for(i=0;i
b[i]=i;
y=fopen("C:Users吃瓜群众Desktop胡鹏宾-2018901231暑假文件kjv.txt","r");
if(y==NULL)
printf("打开文件出错!");
x=fgetc(y);
while(!feof(y))
{
for(i=0;i
{a=b[i];
if(x==a)
c[i]++;
}
x=fgetc(y);
}
for(i=0;i
if(c[i]!=0)
k++;
fclose(y);
for(i=0;i
if(c[i]!=0)
printf("字符%c的个数为%d ",b[i],c[i]);
printf("有%d种字符",k);
}
下面又是时间的转化
#include
void main()
{
int date,month,year,i,j;
char a[12][12]={"January","February","March","April",
"May","June","July","August","September","October","November","December"} ;
while(1)
{
printf("请输入日期如:(2019-7-8) ");
scanf("%d-%d-%d",&year,&month,&date);
if((date
{for(i=0;i
if(month==i+1)
switch(date)
{
case 1:case 11:case 21:case 31:
printf("%dst ",date);
for (j=0;j
printf("%c",a[i][j]);
printf(",%d ",year);
break;
case 2:
printf("%dnd ",date);
for (j=0;j
printf("%c",a[i][j]);
printf(",%d ",year);
break;
case 3:
printf("%drd ",date);
for (j=0;j
printf("%c",a[i][j]);
printf(",%d ",year);
break;
default:
printf("%dth ",date);
for (j=0;j
printf("%c",a[i][j]);
printf(",%d ",year);
}}
else
printf("你输入有误,请重新输入 ");}
}