Code Jam Digital
///////////////////////////////////////////////////////////////////////////////
// digital angka ///
///////////////////////////////////////////////////////////////////////////////
#include<iostream.h>
#include<conio.h>
#define WAIT(x) Sleep((long)(x));
#define SECOND 1000
#include<windows.h>
#include<iostream.h>
#include<conio.h>
class angka
{
public:
angka()
{
}
void satu( int );
void dua( int );
void tiga( int );
void empat( int );
void lima( int );
void enam( int );
void tujuh( int );
void delapan( int );
void sembilan( int );
void nol( int );
void detik( int n );
void puluhan( int, int );
void satuan( int, int );
void titikdua( int );
void menit( int n );
void jam( int n );
};
void angka::titikdua( int i )
{
int huruf[14] [8] =
{
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 1, 1, 1, 0, 0, 0
},
{
0, 0, 1, 1, 1, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 1, 1, 1, 0, 0, 0
},
{
0, 0, 1, 1, 1, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
},
{
0, 0, 0, 0, 0, 0, 0, 0
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::satu( int i )
{
int huruf[14] [8] =
{
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::dua( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::tiga( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::empat( int i )
{
int huruf[14] [8] =
{
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::lima( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::enam( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 0, 0, 0, 0, 0, 0
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::tujuh( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::delapan( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::sembilan( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
0, 0, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::nol( int i )
{
int huruf[14] [8] =
{
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 0, 0, 0, 0, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
},
{
1, 1, 1, 1, 1, 1, 1, 1
}
};
for ( int a = 0; a < 14; a++ )
{
gotoxy( i, a + 15 );
for ( int j = 0; j < 8; j++ )
if ( huruf[a] [j] == 1 )
cout << char( 219 );
else
cout << char( 32 );
cout << endl;
}
}
void angka::satuan( int a, int n )
{
// int n = 53;
if ( a == 0 )
{
nol( n );
}
else if ( a == 1 )
{
satu( n );
}
else if ( a == 2 )
{
dua( n );
}
else if ( a == 3 )
{
tiga( n );
}
else if ( a == 4 )
{
empat( n );
}
else if ( a == 5 )
{
lima( n );
}
else if ( a == 6 )
{
enam( n );
}
else if ( a == 7 )
{
tujuh( n );
}
else if ( a == 8 )
{
delapan( n );
}
else if ( a == 9 )
{
sembilan( n );
}
}
void angka::puluhan( int a, int n )
{
// int n = 44;
if ( a == 0 )
{
nol( n );
}
else if ( a == 1 )
{
satu( n );
}
else if ( a == 2 )
{
dua( n );
}
else if ( a == 3 )
{
tiga( n );
}
else if ( a == 4 )
{
empat( n );
}
else if ( a == 5 )
{
lima( n );
}
else if ( a == 6 )
{
enam( n );
}
else if ( a == 7 )
{
tujuh( n );
}
else if ( a == 8 )
{
delapan( n );
}
else if ( a == 9 )
{
sembilan( n );
}
}
void angka::detik( int n )
{
int s, p, r, rb;
p = ( ( ( ( n % 1000 ) % 100 ) - ( ( ( n % 1000 ) % 100 ) % 10 ) ) / 10 );
s = ( ( ( n % 1000 ) % 100 ) % 10 ) - ( ( ( ( n % 1000 ) % 100 ) % 10 ) % 1 );
satuan( s, 70 );
puluhan( p, 61 );
}
void angka::menit( int n )
{
int s, p, r, rb;
p = ( ( ( ( n % 1000 ) % 100 ) - ( ( ( n % 1000 ) % 100 ) % 10 ) ) / 10 );
s = ( ( ( n % 1000 ) % 100 ) % 10 ) - ( ( ( ( n % 1000 ) % 100 ) % 10 ) % 1 );
satuan( s, 48 );
puluhan( p, 39 );
}
void angka::jam( int n )
{
int s, p, r, rb;
p = ( ( ( ( n % 1000 ) % 100 ) - ( ( ( n % 1000 ) % 100 ) % 10 ) ) / 10 );
s = ( ( ( n % 1000 ) % 100 ) % 10 ) - ( ( ( ( n % 1000 ) % 100 ) % 10 ) % 1 );
satuan( s, 26 );
puluhan( p, 17 );
}
int main()
{
angka x;
gotoxy( 67, 12 ); cout << "DETIK";
gotoxy( 45, 12 ); cout << "MENIT";
gotoxy( 24, 12 ); cout << "JAM";
for ( int jam = 0; jam < 60; jam++ )
{
for ( int menit = 0; menit < 60; menit++ )
{
for ( int detik = 0; detik < 60; detik++ )
{
system( "color 09" );
x.detik( detik );
x.menit( menit );
x.jam( jam );
WAIT( 1 * SECOND );
}
}
}
}
0 komentar:
Posting Komentar