Home > Back-end >  C, ask for advice
C, ask for advice

Time:12-15


Strives for the great god, why any input (date) (month) (year) have no reaction, no output number


# include
Typedef struct {int year, month, day, } the Date;
Void the sum (the Date * p) {
Int [] md={31,28,31,30,31,30,31,31,30,31,30};
Int I, total=0;
for(i=0; i

Total +=md [I];
Total +=p - & gt; day;
If ((p - & gt; Year %==0 400 | | p - & gt; Year % 4==0 & amp; & P - & gt; 100 year %==0) & amp; & P - & gt; Month> 2)
total++;
Printf (" % d ", total); }
Int main () {
The Date d;
The Date * p=& amp; D;
The scanf (" % d % d - % d ", & amp; D.y ear, & amp; D.m onth, & amp; D.d ay); }

CodePudding user response:

 
# include
Typedef struct {
Int year, month, day.
} the Date;

Void the sum (the Date * p)
{
Int [] md={31,28,31,30,31,30,31,31,30,31,30};
Int I, total=0;
for(i=0; i

Total +=md [I];
Total +=p - & gt; day;
//if ((p - & gt; Year %==0 400 | | p - & gt; Year % 4==0 & amp; & P - & gt; 100 year %==0) & amp; & P - & gt; Month> 2)
If ((p - & gt; 400 year %==0 | | (p - & gt; Year % 4==0 & amp; & P - & gt; Year % 100!=0)) & amp; & P - & gt; Month> 2)
total++;
Printf (" % d ", total);
}
Int main ()
{
The Date d;
The Date * p=& amp; D;
The scanf (" % d % d - % d ", & amp; D.y ear, & amp; D.m onth, & amp; D.d ay);
The sum (p);

return 0;
}


For your reference ~

The landlord did not call the sum function, so there is no output

Other problems can be found in the above code

CodePudding user response:

BTW:
Make it a habit to write code in a standard format,
You think like this, I am 20 dollars a line of code, curly braces are not independent a line loss,