Jump to content

[REZOLVAT] Problema GetWeekDay.


Nurdock
 Share

Recommended Posts

  • Retired
Salut, am o problema la functia getweekday deoarece daca sa zicem e sambata si folosesc functia aia imi zice ca este luni.
 
Functie:
GetWeekDay(day=0, month=0, year=0)
{
  if (!day)
    getdate(year, month, day);

  new
    weekday,
    j,
    e
  ;

  if (month <= 2)
  {
    month += 12;
    --year;
  }

  j = year % 100;
  e = year / 100;

  switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)
  {
    case 0: weekday = 1;
    case 1: weekday = 2;
    case 2: weekday = 3;
    case 3: weekday = 4;
    case 4: weekday = 5;
    case 5: weekday = 6;
    case 6: weekday = 7;
  }

  return weekday;
}

Va multumesc.

 

Link to comment
Share on other sites

Ai aici lista cu zilele din switch in ordinea corecta:

 

switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)

{

case 0: weekday_str = "Saturday";

case 1: weekday_str = "Sunday";

case 2: weekday_str = "Monday";

case 3: weekday_str = "Tuesday";

case 4: weekday_str = "Wednesday";

case 5: weekday_str = "Thursday";

case 6: weekday_str = "Friday";

}

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

  • Retired

Ai aici lista cu zilele din switch in ordinea corecta:

 

switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)

{

case 0: weekday_str = "Saturday";

case 1: weekday_str = "Sunday";

case 2: weekday_str = "Monday";

case 3: weekday_str = "Tuesday";

case 4: weekday_str = "Wednesday";

case 5: weekday_str = "Thursday";

case 6: weekday_str = "Friday";

}

we, nu asta e problema mea, eu asa am nevoie cum am pus acolo in switch sa imi dea o valoare pentru fiecare zi dar imi da cu 2 zile in fata, daca e sambata imi da luni s.a.m.d.

Link to comment
Share on other sites

Eu ti am dat lista, sa poti vedea unde ai gresit. Verificarea o faci singur.

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

  • Retired

Ai aici lista cu zilele din switch in ordinea corecta:

 

switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)

{

case 0: weekday_str = "Saturday";

case 1: weekday_str = "Sunday";

case 2: weekday_str = "Monday";

case 3: weekday_str = "Tuesday";

case 4: weekday_str = "Wednesday";

case 5: weekday_str = "Thursday";

case 6: weekday_str = "Friday";

}

case 0: weekday = 1; //luni

case 1: weekday = 2; //marti

case 2: weekday = 3; //miercuri

case 3: weekday = 4; //joi

case 4: weekday = 5; //vineri

case 5: weekday = 6; //sambata

case 6: weekday = 7; //duminica

Nu e corect cum am pus????

Link to comment
Share on other sites

Atunci nu le-ai modificat bine in int. In lista de la mine, case 0 = saturday => 6, la tine case 0 = 1 => luni.

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...