Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
chazog
/
iax0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
41155144
authored
Dec 16, 2018
by
chazog
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
7d2aa165
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
Lab2/Gregorian calendar.c
Lab2/Gregorian calendar.c
0 → 100644
View file @
41155144
#include <stdio.h>
int
main
()
{
int
num
,
dd
,
mm
,
yy
;
printf
(
"Please enter the date ddmmyy:
\n
"
);
scanf
(
"%d"
,
&
num
);
dd
=
num
/
1000000
;
mm
=
(
num
%
1000000
)
/
10000
;
yy
=
(
num
%
10000
);
printf
(
"%d,%d,%d
\n
"
,
dd
,
mm
,
yy
);
int
bissextile
=
yy
%
400
==
0
||
(
yy
%
4
==
0
&&
yy
%
100
!=
0
);
if
(
dd
>
31
||
dd
<
1
||
mm
>
12
||
mm
<
1
)
printf
(
"Invalid date.
\n
"
);
if
((
mm
==
2
&&
dd
<
30
&&
bissextile
)
||
(
mm
==
2
&&
dd
<
29
&&
bissextile
==
0
))
printf
(
"valid date.
\n
"
);
else
if
((
mm
==
4
||
mm
==
6
||
mm
==
9
||
mm
==
11
)
&&
dd
<
31
)
printf
(
"valid date.
\n
"
);
else
if
(
dd
<
31
&&
mm
!=
2
)
printf
(
"valid date.
\n
"
);
else
printf
(
"Invalid date.
\n
"
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment