#include <stdio.h>
void main()
{
int year,m,date,c=0;
for(scanf("%4d%2d%2d",&year,&m,&date);m>1;m--)
{
(m-1==4||m-1==6||m-1==9||m-1==11)?c+=c:(m==2)?((year%4==0&&year%100!=0||year%400==0)?c+=29:c+=28):c+=31;
}
printf("%d\n",c=c+date);
}
#include <stdio.h>
void main()
{
int year,m,date,c=0;
for(scanf("%4d%2d%2d",&year,&m,&date);m>1;m--)
{
(m-1==4||m-1==6||m-1==9||m-1==11)?c+=c:(m==2)?((year%4==0&&year%100!=0||year%400==0)?c+=29:c+=28):c+=31;
}
printf("%d\n",c=c+date);
}
1. 有加减乘除运算的话,需要加上 math.h
2. 这题的运算结果有误,我输入2002 12 31 显示的是结果是679
#include <stdio.h>
#include <math.h>
void main()
{
int year,m,date,c=0;
for(scanf("%4d%2d%2d",&year,&m,&date);m>1;m--)
{
(m-1==4||m-1==6||m-1==9||m-1==11)?c+=30:(m-1==2)?((year%4==0&&year%100!=0||year%400==0)?c+=29:c+=28):c+=31; //4,6,9,11月的日子是30天,m-1 == 2 才是2月的,不然输入3月的日子可能就不对了
}
printf("%d\n",c=c+date);
}
具体问题具体对待,这个程序得运行是没有问题的,要看报出的是什么错,可能是环境没有搭好
printf("%d\n",c=c+date);
scanf("%4d%2d%2d",&year,&m,&date);
vc下面不认识
应该用cin,cout