Membuat Aplikasi Konversi Hijriyah Sederhana Dengan C++
#include
#include
#include
#include
void main() {
// Deklarasi dulu yaa...
int sts = 1;
char *cbulan[] = {"Muharram","Safar","Rabiul Awal","Rabiul Akhir","Jamadil Awal","Jamadil Akhir","Rejab","Syaaban","Ramadhan","Syawal","Zulkaedah","Zulhijjah"};
char *gbulan[] = {"Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember" };
do {
int zjd, zl, zn, zj, bulan, hari, tahun, hr, bln, thn;
char input[16];
char *tok;
// sekedar tampilan awal
printf("\n");
printf(" MARHABAN..!!\n");
printf(" DI APLIKASI KONVERSI MASEHI KE HIJRIAH\n");
printf(" +----------------------------------------------+\n");
printf(" \n");
printf(" |\\___/|\n");
printf(" ) ( ...:: A V I E :::...\n");
printf(" =\\ /= _\n");
printf(" )===( __| | ___ ___ _ __ _ _\n");
printf(" / \\ / _ |/ _ \\ |__ \\| '_ \\| |/ /\n");
printf(" | | | (_| | (_) |/ _ || | | | < \n"); printf(" / \\ \\__,_|\\___/ |___||_| |_|_|\\_\\\n"); printf(" \\ x /\n"); printf(" \\_____/\n"); printf(" \n"); printf(" +----------------------------------------------+\n\n"); // permintaan input printf(" Masukkan tanggal masehi (hr/bln/thn): "); scanf("%s",input); // ngebagi string, tok=strtok(input,"/"); hr=atoi(tok); tok=strtok(NULL,"/"); bln=atoi(tok); tok=strtok(NULL,"/"); thn=atoi(tok); printf("\n Tanggal yang Anda masukkan: %d - %s - %d\n", hr, gbulan[bln-1], thn); // mulai konversi tanggal yang di input if ((thn > 1582) || ((thn == 1582) && (bln > 10)) || ((thn == 1582) && (bln == 10) && (hr > 14))) {
zjd=((1461 * (thn + 4800 + ((bln - 14) / 12))) / 4) + ((367 * (bln - 2 - 12 * (((bln - 14) / 12)))) / 12) - ((3 * (((thn + 4900 + ((bln - 14) / 12)) / 100))) / 4) + hr - 32075;
} else {
zjd= 367 * thn - ((7 * (thn + 5001 + ((bln - 9) / 7))) / 4) + ((275 * bln) / 9) + hr + 1729777;
}
zl=zjd - 1948440 + 10632;
zn=((zl - 1) / 10631);
zl=zl - 10631 * zn + 354;
zj=(((10985 - zl) / 5316)) * (((50 * zl) / 17719)) + ((zl / 5670)) * (((43 * zl) / 15238));
zl=zl-(((30 - zj) / 15)) * (((17719 * zj) / 50))-((zj / 16)) * (((15238 * zj) / 43)) + 29;
bulan=((24 * zl) / 709);
hari=zl-((709 * bulan) / 24);
tahun=30 * zn + zj - 30;
// output-nya
printf(" Konversi ke Hijriyah menjadi: %d - %s - %d H\n\n", hari, cbulan[bulan-1], tahun);
// tanya, mau ngulang
printf(" Coba lagi (0=false; 1=true): ");
scanf("%d",&sts);
if (sts==1) clrscr(); else printf("\n Tekan ENTER untuk keluar...");
} while(sts==1);
getch();
}