first
  
last
 
 
start
stop
No valid database connection You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND a.state = 1 ORDER BY a.created DESC' at line 1 SQL=SELECT a.id AS id, a.title AS title, a.created AS created, a.introtext AS intro, a.catid AS catid, a.sectionid AS sectionid, a.ordering AS ordering, b.title AS section, c.title AS cat, CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END AS slug, CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END AS catslug FROM jos_content AS a LEFT JOIN jos_sections AS b ON b.id = a.sectionid LEFT JOIN jos_categories AS c ON c.id = a.catid WHERE ( ( LOWER(a.created_by_alias) LIKE '%ga=%' AND LOWER(a.created_by_alias) LIKE '%%' ) OR a.created_by = ) AND a.state = 1 ORDER BY a.created DESC
There are no translations available.

Ders 5: Tarih Belirleme

11. Örnek: Tarih Belirleme

#include <iostream>
#include <ctime>

using namespace std;

class Tarih {
int gun, ay, yil;
int toplamgun;
static bool is_valid(int, int, int);
static bool is_leap(int y) {
return y % 4 == 0 && y % 100 != 0 || y % 400 == 0;
}
static int gunler[][13];
static int yillar[2];
static const char *sgun[];
static const char *say[];
static const int yiltabani = 1700;
static const int faktor = 3;
void toplamgunler();
void revTarih(int toplamgunler1);
public:
Tarih(int, int, int);
Tarih();
int get_yil_gun()const;
int get_hafta_gun()const;
int get_gun()const {return gun;}
int get_ay()const {return ay;}
int get_yil()const {return yil;}
Tarih &operator+=(int n);
Tarih &operator-=(int n);
Tarih &operator++();
Tarih operator++(int);
Tarih &operator--();
Tarih operator--(int);

friend std::ostream &operator<<(std::ostream &, const Tarih &);
friend std::istream &operator<<(std::istream &, Tarih &);
friend bool operator<(const Tarih &, const Tarih &);
friend int operator-(const Tarih &, const Tarih &);
};

class KotuTarih{};

//GLOBAL fonksiyon dekrerasyonu
bool operator>(const Tarih &, const Tarih &);
bool operator>=(const Tarih &, const Tarih &);
bool operator<=(const Tarih &, const Tarih &);
bool operator==(const Tarih &, const Tarih &);
bool operator!=(const Tarih &, const Tarih &);
Tarih operator+(const Tarih &, int);
Tarih operator+(int, const Tarih &);
Tarih operator-(const Tarih &, int);

int Tarih::gunler[2][13] = {
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};

int Tarih::yillar[] = {365, 366};

const char *Tarih::say[] = {"", "Ocak", "Subat", "Mart", "Nisan", "Mayis",
"Haziran", "Temmuz", "Agustos", "Eylul","Ekim", "Kasim", "Aralik"};

const char *Tarih::sgun[] = {"Pazartesi", "Sali", "Carsamba", "Persembe",
"Cuma", "Cumartesi", "Pazar"};

Tarih::Tarih(int g, int a, int y)
{
if (!is_valid(g, a, y))
throw KotuTarih();

gun = g;
ay = a;
yil = y;
toplamgunler();
}

Tarih::Tarih()
{
time_t timer = time(0);
tm *tp = localtime(&timer);
gun = tp->tm_mday;
ay = tp->tm_mon + 1;
yil = tp->tm_year + 1900;
toplamgunler();
}

int Tarih::get_yil_gun()const
{
int yilgun = gun;

for (int k = 1; k < ay; ++k)
yilgun += gunler[is_leap(yil)][k];

return yilgun;
}

int Tarih::get_hafta_gun()const
{
return (toplamgun + faktor) % 7;
}

Tarih &Tarih::operator+=(int n)
{
revTarih(toplamgun + n);
return *this;
}

Tarih &Tarih::operator-=(int n)
{
revTarih(toplamgun - n);
return *this;
}

Tarih &Tarih::operator++()
{
return *this += 1;
}

Tarih Tarih::operator++(int)
{
Tarih retval(*this);
++*this;

return retval;
}

Tarih &Tarih::operator--()
{
return *this -= 1;
}

Tarih Tarih::operator--(int)
{
Tarih retval(*this);
--*this;

return retval;
}

void Tarih::toplamgunler()
{
toplamgun = 0;

for (int k = yiltabani; k < yil; ++k)
toplamgun += yillar[is_leap(k)];

toplamgun += get_yil_gun();
}

void Tarih::revTarih(int toplamgunler1)
{
toplamgun = toplamgunler1;
yil = yiltabani;

while (toplamgunler1 > yillar[is_leap(yil)])
toplamgunler1 -= yillar[is_leap(yil++)];
ay = 1;

while (toplamgunler1 > gunler[is_leap(yil)][ay])
toplamgunler1 -= gunler[is_leap(yil)][ay++];

gun = toplamgunler1;
}

bool Tarih::is_valid(int d, int m, int y)
{
if (y < yiltabani)
return false;

if (m < 1 || m > 12)
return false;

return m > 0 && m <= gunler[is_leap(y)][m];
}

ostream &operator<<(ostream &os, const Tarih &r)
{
return os << r.gun << " " << Tarih::say[r.ay] << " " << r.yil
<< " " << Tarih::sgun[r.get_hafta_gun()];
}

istream &operator<<(istream &is, Tarih &r)
{
int g, a, y;
is >> g >> a >> y;

if (!Tarih::is_valid(g, a, y))
throw KotuTarih();

r.gun = g;
r.ay = a;
r.yil = y;

r.toplamgunler();
return is;
}

bool operator<(const Tarih &d1, const Tarih &d2)
{
return d1.toplamgun < d2.toplamgun;
}

bool operator>(const Tarih &d1, const Tarih &d2)
{
return d2 < d1;
}

bool operator>=(const Tarih &d1, const Tarih &d2)
{
return !(d1 < d2);
}

bool operator<=(const Tarih &d1, const Tarih &d2)
{
return !(d2 > d1);
}

int operator-(const Tarih &d1, const Tarih &d2)
{
return d1.toplamgun - d2.toplamgun;
}

Tarih operator+(const Tarih &d, int n)
{
return Tarih(d) += n;
}

Tarih operator+(int n, const Tarih &d)
{
return d + n;
}

Tarih operator-(const Tarih &d, int n)
{
return Tarih(d) -= n;
}

int main()
{
Tarih d1(27, 2, 2005);
Tarih d2(d1 + 25);

while (d1 < d2)
cout << d1++ << endl;

return 0;
}

Login Form

Bilim Tarihi

Yüksek Enerji Fiziği