#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
string a = "Binary -> Decimal by gh0st Evilzone.org\n";cout<< a;
cout << "enter a binary number of 4 figures: \n";
cin >> x;
if (x == 1)
{
cout << "the number in decimal is 1\n";
system("pause");
return 0;
}
if (x == 11)
{
cout << "the number in decimal is 3\n";
system("pause");
return 0;
}
if (x == 1011)
{
cout << "the number in decimal is 11\n";
system("pause");
return 0;
}
if (x == 1110)
{
cout << "the number in decimal is 14\n";
system("pause");
return 0;
}
if (x == 111 )
{
cout << "the number in decimal is 7\n";
system("pause");
return 0;
}
if (x == 1101)
{
cout << "the number in decimal is 13\n";
system("pause");
return 0;
}
if (x == 1000 )
{
cout << "the number in decimal is 8\n";
system("pause");
return 0;
}
if (x == 100 )
{
cout << "the number in decimal is 4\n";
system("pause");
return 0;
}
if (x == 10 )
{
cout << "the number in decimal is 2\n";
system("pause");
return 0;
}
if (x == 1111 )
{
cout << "the number in decimal is 15\n";
system("pause");
return 0;
}
if (x == 0000 )
{
cout << "the number in decimal is 0\n";
system("pause");
return 0;
}
if (x == 1010 )
{
cout << "the number in decimal is 10\n";
system("pause");
return 0;
}
if (x == 101)
{
cout << "the number in decimal is 5\n";
system("pause");
return 0;
}
if (x == 110 )
{
cout << "the number in decimal is 6\n";
system("pause");
return 0;
}
if (x == 1100)
{
cout << "the number in decimal is 12\n";
system("pause");
return 0;
}
if (x == 1001 )
{
cout << "the number in decimal is 9\n";
system("pause");
return 0;
}
else
{
cout << "error invalid input\n";
system("pause");
return 0;
}
}
Dim Bytes() as byte
Dim ByteString as string = ""
For Each Bit as byte in Bytes
Bytestring &= byte.tostring
next
this will already be in decimal numbers.Dim Bytes() as byte = System.Text.ASCIIEncoding.ASCII.GetBytes("Hello world!")
and for reverse of the code Above:Dim Bytes() as byte = System.Text.ASCIIEncoding.ASCII.GetBytes("Hello world!")
DIm StringLine as string = System.text.ASCIIEncoding.ASCII.getstring(Bytes)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
string a = " \n"; cout << a;
string b = " EVILZONE \n"; cout << b;
string c = " \n"; cout << c;
string d = " \n"; cout << d;
string e = " &&& \n"; cout << e;
string f = " <o.o> \n"; cout << f;
string g = " \\-/ \n"; cout << g;
string h = " W \n"; cout << h;
string i = " /|\\ \n"; cout << i;
string j = " / | \\ \n"; cout << j;
string k = " O | O \n"; cout << k;
string l = " / \\ \n"; cout << l;
string m = " / \\ \n"; cout << m;
string n = " / \\ \n"; cout << n;
string o = " () () \n"; cout << o;
cout << "enter a binary number of 4 figures: \n";
cin >> x;
if (x == 1)
{
cout << "the number in decimal is 1\n";
system("pause");
return 0;
}
if (x == 11)
{
cout << "the number in decimal is 3\n";
system("pause");
return 0;
}
if (x == 1011)
{
cout << "the number in decimal is 11\n";
system("pause");
return 0;
}
if (x == 1110)
{
cout << "the number in decimal is 14\n";
system("pause");
return 0;
}
if (x == 111 )
{
cout << "the number in decimal is 7\n";
system("pause");
return 0;
}
if (x == 1101)
{
cout << "the number in decimal is 13\n";
system("pause");
return 0;
}
if (x == 1000 )
{
cout << "the number in decimal is 8\n";
system("pause");
return 0;
}
if (x == 100 )
{
cout << "the number in decimal is 4\n";
system("pause");
return 0;
}
if (x == 10 )
{
cout << "the number in decimal is 2\n";
system("pause");
return 0;
}
if (x == 1111 )
{
cout << "the number in decimal is 15\n";
system("pause");
return 0;
}
if (x == 0000 )
{
cout << "the number in decimal is 0\n";
system("pause");
return 0;
}
if (x == 1010 )
{
cout << "the number in decimal is 10\n";
system("pause");
return 0;
}
if (x == 101)
{
cout << "the number in decimal is 5\n";
system("pause");
return 0;
}
if (x == 110 )
{
cout << "the number in decimal is 6\n";
system("pause");
return 0;
}
if (x == 1100)
{
cout << "the number in decimal is 12\n";
system("pause");
return 0;
}
if (x == 1001 )
{
cout << "the number in decimal is 9\n";
system("pause");
return 0;
}
else
{
cout << "error invalid input\n";
system("pause");
return 0;
}
}
1) You should never use system calls (like system("pause")) when it's not absolutely needed.
____ _ _ _ _
/ ___|___ _ __ __ _ _ __ __ _| |_ _ _| | __ _| |_(_) ___ _ __ ___
| | / _ \| '_ \ / _` | '__/ _` | __| | | | |/ _` | __| |/ _ \| '_ \/ __|
| |__| (_) | | | | (_| | | | (_| | |_| |_| | | (_| | |_| | (_) | | | \__ \
\____\___/|_| |_|\__, |_| \__,_|\__|\__,_|_|\__,_|\__|_|\___/|_| |_|___/
|___/
''' <summary>
''' Convert a number to Byte(1010011)
''' </summary>
''' <param name="Number">the number to convert</param>
''' <returns>the byte in a string</returns>
''' <remarks></remarks>
Function toByte(ByVal Number As Integer) As String
Dim Bytes As New List(Of String)
While Number <> 0
Dim I As Integer
For I = 1 To Number
If 2 ^ (I + 1) > Number Then Exit For
Next
Number -= (2 ^ I)
Bytes.Add(I)
End While
Dim ByteStr As New List(Of String)
For J As Integer = 0 To Bytes(0)
ByteStr.Add("0")
Next
For J As Integer = 0 To Bytes.Count - 1
ByteStr(Bytes(J)) = 1
Next
Return Join(ByteStr.ToArray.Reverse.ToArray, "")
End Function
''' <summary>
''' Converts a Byte (in String) to Decimal
''' </summary>
''' <param name="Bytes"></param>
''' <returns></returns>
''' <remarks></remarks>
Function toDecimal(ByVal Bytes As String) As Integer
Dim R As Integer = 0
Dim D As Integer = Bytes.Length
For I As Integer = 1 To Bytes.Length
Dim Bit As Integer = CInt(Mid(Bytes, I, 1))
If Bit = 1 Then
R += 2 ^ (D - I)
End If
Next
Return R
End Function
what the program does is to decode binary numbers (for example 0010 to 2) in decimal but just numbers of 4 characters no more.
well I wanted to add an ASCII art of EVILZONE but I cant
can someone help me plz? :(
award: +2 of karma
#include <bitset>
#include <iostream>
#include <string>
int main ()
{
cout << "Binary -> Decimal by gh0st Evilzone.org" << endl;
string x = "";
cout << "enter a binary number of 4 figures:" << endl;
cin >> x;
bitset<4> binary (x); // initialize from string
cout << "The number in decimal is " << binary.to_ulong() << endl;
return 0;
}