S
yo super, beide Lösungen sehen auf jeden Fall besser aus als mein Denkansatz!
Ich werde es mal ausarbeiten und den fertigen Code für die Nachwelt einstellen.
Viel Dank an Euch beide!
Edit: fertig!
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main(void)
{
int dayofyear, year, month, monthptr, *dayofmonth;
static int daysofmonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
printf("Bitte geben Sie das Jahr ein:\n");
scanf ("%d", &year);
printf("\nBitte geben Sie nun den Tag ein:\n");
scanf ("%d", &dayofyear);
if ((year % 400) == 0)
daysofmonth[1] = 29;
else if ((year % 100) == 0)
daysofmonth[1] = 28;
else if ((year % 4) == 0)
daysofmonth[1] = 29;
else
daysofmonth[1] = 28;
for( month=0; month<12 && dayofyear>daysofmonth[month]; month++ )
dayofyear = dayofyear-daysofmonth[month];
monthptr = month+1;
*dayofmonth = dayofyear;
printf("\nDas Datum lautet: %d.%d.%d",*dayofmonth,monthptr,year);
getch();
}