1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include <iostream>
#include <string>
using namespace std;
//Function Prototype
int reverseint(int);
int pow(int b, int e);
int main() {
string codes[] = {
"||:::", ":::||", "::|:|", "::||:", ":|::|", ":|:|:", ":||::", "|:::|", "|::|:", "|:|::"
};
int zip;
cin >> zip;
//Reversing Integer
zip = reverseint(zip);
while( zip > 0 ) {
cout << codes[zip % 10];
zip /= 10;
}
return 0;
}
int reverseint(int num)
{
int size = 0, result = 0;
int x = num;
//Calculating Size of num
while(x>0)
{
x /= 10;
size++;
}
x = num;
for(int i=0;i<size;i++)
result += ( ( ( x % pow(10,i+1) ) / pow(10,i) ) * pow(10, size-(i+1)) );
return result;
}
int pow(int b, int e)
{
int result = 1;
for(int i=0;i<e;i++)
{
result *= b;
}
return result;
}
|