#include<iostream>
using namespace std;
unsigned long hari=0;
void calender(int n);
void main()
{
int i,bln,thn;
cout<<endl<<endl<<" \t\t\tProgram Kalender"<<endl<<endl<<endl;
cout<<" Inputkan bulan yang Anda mau : bulan ke-";
cin>>bln;
cout<<" Inputkan tahun yang Anda mau : tahun ";
cin>>thn;
cout<<endl<<endl<<endl;
cout<<" \tKalender bulan ke-"<<bln<<" tahun "<<thn<<endl;
for(i=1;i<thn;i++)
{
if(i%4==0 && i%100!=0 || i%4==0 && i%100==0 && i%400==0)
hari+=366;
else
hari+=365;
}
for(i=1;i<bln;i++)
{
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
hari+=31;
else if(i==4||i==6||i==9||i==11)
hari+=30;
else if(i==2 && thn%4==0 && thn%100!=0 || thn==2 && thn%4==0 && thn%100==0 && thn%400==0)
hari+=29;
else
hari+=28;
}
{
if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
calender(31);
else if(i==4||i==6||i==9||i==11)
calender(30);
else if(i==2 && thn%4==0 && thn%100!=0 || thn==2 && thn%4==0 && thn%100==0 && thn%400==0)
calender(29);
else
calender(28);
}
}
void calender(int n)
{
cout<<" \t-----------------------------------------------------"<<endl;
cout<<" \tSEN\tSEL\tRAB\tKAM\tJUM\tSAB\tMING"<<endl;
cout<<" \t-----------------------------------------------------"<<endl;
int sisa_hari=hari%7;
int i=1;
while (i<=sisa_hari)
{
cout<<"\t";
i++;
}
while (i<=n)
{
cout<<"\t"<<i;
if((i+sisa_hari)%7==0)
cout<<"\n";
i++;
}
cout<<endl;
cout<<" \t-----------------------------------------------------"<<endl<<endl<<endl<<endl;
system ("pause");
}
Tidak ada komentar:
Posting Komentar