c程序由变量换成指针变量,编译没错,但是运行出错,请问为什么,??下面是源程序
#include<stdio.h>main()
{ int year,month,date,hour,minute,second,day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
printf("请输入时间:");
scanf("%d%d%d%d%d%d",&year,&month,&date,&hour,&minute,&second);
if(year%400==0||year%100!=0&&year%4==0)
day[1]=29;
if(year>=0&&month>=1&&month<=12&&date>=1&&date<=day[month-1]&&hour>=0&&hour<=23&&minute>=0&&minute<=59&&second>=0&&second<=59)
{ second+=1;
if(second==60)
{second=0;
minute+=1;}
if(minute==60)
{minute=0;
hour+=1;}
if(hour==24)
{hour=0;
date+=1;}
if(date>day[month-1])
{date=1;
month+=1;}
if(month==13)
{month=1;
year+=1;}
printf("%d年%d月%d日%d时%d分%d秒\n",year,month,date,hour,minute,second);
}
else
printf("输入错误");
}
这个运行成功出结果,
#include<stdio.h>
main()
{ int *year,*month,*date,*hour,*minute,*second,day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
printf("请输入时间:");
scanf("%d%d%d%d%d%d",year,month,date,hour,minute,second);
if(*year%400==0||*year%100!=0&&*year%4==0)
day[1]=29;
if(*year>=0&&*month>=1&&*month<=12&&*date>=1&&*date<=day[*month-1]&&*hour>=0&&*hour<=23&&*minute>=0&&*minute<=59&&*second>=0&&*second<=59)
{ *second+=1;
if(*second==60)
{*second=0;
*minute+=1;}
if(*minute==60)
{*minute=0;
*hour+=1;}
if(*hour==24)
{*hour=0;
*date+=1;}
if(*date>day[*month-1])
{*date=1;
*month+=1;}
if(*month==13)
{*month=1;
*year+=1;}
printf("%d年%d月%d日%d时%d分%d秒",*year,*month,*date,*hour,*minute,*second);
}
else
printf("输入错误");
}
这个运行出错,请问问题在哪?