Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Datumscheck
- #include <stdio.h>
- void main()
- {
- system("chcp 1252");
- system("cls");
- int t,m,j;
- int monatstage[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- int check = 0;
- printf("Bitte geben Sie ein Datum im Format tt.mm.jjjj ein:");
- scanf("%i.%i.%i",&t,&m,&j);
- // Prüfung Schaltjahr
- if(j % 400 == 0 || (j % 100 != 0 && j % 4 == 0))
- monatstage[1]=29;
- // Prüfung Tage im Monat
- if (m < 13)
- {
- if( t <= monatstage[m-1] )
- check=1;
- }
- if (check==1)
- printf("Es ist ein gültiges Datum!\n");
- else
- printf("Es ist kein gültiges Datum!\n");
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement