join lines 18 and 19 in your code please
join lines 18 and 19 in your code please
I checked again, but PHP generated dates are not always on Sunday - so wrong!
This works in C++ and it seems that the correct:
#include <sstream>
#include <iostream>
using namespace std;
string ZeroPadNumber(int num){
stringstream ss;
// the number is converted to string with the help of stringstream
ss << num;
string ret;
ss >> ret;
// Append zero chars
int str_length = ret.length();
for (int i = 0; i < 2 - str_length; i++)
ret = "0" + ret;
return ret;
}
void EasterDate(int X){ // X = year to compute
int K, M, S, A, D, R, OG, SZ, OE;
K = X / 100; // Secular number
M = 15 + (3 * K + 3) / 4 - (8 * K + 13) / 25; // Secular Moon shift
S = 2 - (3 * K + 3) / 4; // Secular sun shift
A = X % 19; // Moon parameter
D = (19 * A + M) % 30; // Seed for 1st full Moon in spring
R = D / 29 + (D / 28 - D / 29) * (A / 11); // Calendarian correction quantity
OG = 21 + D - R; // Easter limit
SZ = 7 - (X + X / 4 + S) % 7; // 1st sunday in March
OE = 7 - (OG - SZ) % 7; // Distance Easter sunday from Easter limit in days
//Easter = DateSerial(X, 3, OG + OE); // Result: Easter sunday as number of days in March
cout << X << "-" << ZeroPadNumber(((OG + OE)>31)?4:3) << "-" << ZeroPadNumber((((OG + OE)%31)==0)?31:((OG + OE)%31));
}
int main ()
{
int year;
do {
cout << "Put the year: ";
cin >> year;
EasterDate(year);
cout << endl << endl;
}
while (year>0);
return 0;
}
ddanbe, I compared to a built-in PHP function "easter_date()" and adjust alghoritm to C++
#include <iostream>
using namespace std;
void EasterDate(int Year)
{
// Gauss Calculation
////////////////////
int Month = 3;
// Determine the Golden number:
int G = Year % 19 + 1;
// Determine the century number:
int C = Year / 100 + 1;
// Correct for the years who are not leap years:
int X = ( 3 * C ) / 4 - 12;
// Mooncorrection:
int Y = ( 8 * C + 5 ) / 25 - 5;
// Find sunday:
int Z = ( 5 * Year ) / 4 - X - 10;
// Determine epact(age of moon on 1 januari of that year(follows a cycle of 19 years):
int E = ( 11 * G + 20 + Y - X ) % 30;
if (E == 24) {E++;}
if ((E == 25) && (G > 11)) {E++;}
// Get the full moon:
int N = 44 - E;
if (N < 21) {N = N + 30;}
// Up to sunday:
int P = ( N + 7 ) - ( ( Z + N ) % 7 );
// Easterdate:
if ( P > 31 )
{
P = P - 31;
Month = 4;
}
cout << Year << "." << Month << "." << P;
}
int main ()
{
int year;
for(int i=1970; i<2038; i++){
EasterDate(i);
cout << endl;
}
return 0;
}
…I solved your project syntax, but alghoritm not correct
// EasterProject
#include<iostream>
using namespace std;
int main()
{
int intyear, intEasterDate, intEasterMonth;
int a, b, c, d, e, f, g, h, i, j, k, m, p;
do {
cout<< "What's the year? \n";
cin>> intyear;
cout<<"Easter Month is \n";
if (intyear<0001||intyear>5000)
{ cout<<"This calculator cannot serve you\n";
return -1; }
a=intyear%19;
b=intyear/100;
c=intyear%100;
d=b/4;
e=b%4;
f=(b+8)/25;
g=(b-f+1)/3;
h=((19*a)+b-d-g+15)%30;
i=c/4;
j=c%4;
k=(32+(2*e)+(2*i)-h-j)%7;
m=(a+(11*h)+(22*k))/451;
intEasterMonth=(h+k-(7*m)+114)/31;
p=(h+k-(7*m)+114)%31;
intEasterDate=p+1;
cout << intEasterMonth << "." << intEasterDate << "\n\n";
} while (intyear>=0001&&intyear<=5000);
return 0;
}
if($rows==1)
is not good "1" can be understood as TRUE considered as 1 or 2 or 3 or etc
Your sql query $log=mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' ");
ignored upper/lower letters and considers "e"=="é" etc, i recommended this: $log=mysql_query("SELECT * FROM users WHERE username LIKE BINARY '$username' AND password LIKE BINARY '$password' ");
function my_opendir($dir) {
if ($handle = opendir($dir)) {
echo "<ul>Directory handle: $dir<br />Entries:";
while (false !== ($entry = readdir($handle))) {
if($entry=="."||$entry=="..") { continue; }
echo "<li>";
if(is_dir($dir.$entry)) { my_opendir($dir.$entry); }
else { echo $entry; }
echo "</li>";
}
echo "</ul>";
closedir($handle);
}
}