I have a trouble with my home work in computer courses. Here the exercise;
The time worked form is a cube whose axes are: year, month, day of the month.
Fill a three-dimensional array with data from 0 to 10 for 2015 - 2020. Request to enter the calendar number dd.mm.yy and give out the number of hours worked on that day.
Firstly i took numbers, then i gave a answer with the number or work hours,
how I understand i need make a matrix( jne side is days, another side is months and third side is year, but i dont know how to do it
firstly i try to train with 2 dimension array,
when i used such formula
Code:
for (i = 0; i < Months; i++)
{
for (j = 0; j < Days; j++)
Cal[i][j] = i,j;
}
for (i = 0; i < Months; i++)
{
for (j = 0; j < Days; j++)
printf("%i", Cal[i][j]);
the matrix was like this
0000
1111
2222
3333
but dont like
0123
1
2
how i expect.
i think its must be one side is months, one side is days, inside of it is hours, and somewhere is years;
here the code what i write, its not complete exercise, need some help with solving and explaining. If you give me a links on a good books and videos for c, its will be good too,
Code:
//
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include "time.h"
#define Years 6
#define Months 12
#define Days 31
int main()
{
srand(time(NULL));
int y, m, d;
int Cal[12][31][1];
int i, j,k = 0;
int h = rand() % 10;
//take information
do {
printf("Enter the year\n");
scanf_s("%i", &y);
if (y < 2015||y>2020)
printf("Wrong year\n");
} while (y < 2015 || y>2020);
do {
printf("Enter the month\n");
scanf_s("%i", &m);
if (m < 1 || m>12)
printf("Wrong month\n");
} while (y < 1 || m>12);
do {
printf("Enter the day\n");
scanf_s("%i", &d);
if (d < 1 || d>31)
printf("Wrong day\n");
} while (d < 1 || d>31);
// give how many work hours in this day person have
printf("For day %i month %i year %i \n", d, m, y);
printf("You have %i work hours", h);
for (i = 0; i < Months; i++)
{
for (j = 0; j < Days; j++)
{
for (k = 0; k < Years; k++)
k = y;
Cal[i][j][k];
}
}
}