أحد يستطيع أن يساعدني في إختصار هذا البرنامج وأضنه مفهوم ولكنه طويل جداً وفكرته هي أدخل رقم من 1 إلى 15 ويعطيك رمزها بل Binary, decimal, hexdecimal ,octal و التحويل من system to an other system
أنا حاولة في فكرة معادلة لتحويل Number to Binary code بس ماحصلت لكل الأرقام يعني ولو أدخل 21455 يعطيك code تبعة في Number System وش رايكم
#include
int main()
{
int n,k,c,d,o,s;
cout<<" ttt The Name of Allahn";
cout<<"ttt***********************************n";
cout<<"ttt** Welcome to Computer program **n";
cout<<"ttt***********************************n";
cout<<" This program you can know Numbers System codes n";
cout<<"and convert Number(Code)from system to an other.n";
cout<<"t/////////////////////////////////////////////////////////////n";
cout<<"t// 1- Hexdecimal to Binary. 2-Binary to Hexdecimal.//n";
cout<<"t// 3- Decimal to Octal. 4-Octal to Decimal. //n";
cout<<"t// 5- Decimal to all Systems //n";
cout<<"t/////////////////////////////////////////////////////////////n";
cout<<"Please select any one from this to convert from system to an other.n";
cin>>n;
if ( n==1)
{
cout<<" please enter your number in Hexdecimal.from (0 to 15)n";
cin>>k;
if(k==0)
cout<<"tt (0)Hexdecimal=(0000)Binn";
else if(k==1)
cout<<"tt (1)Hexdecimal=(0001)Binn";
else if(k==2)
cout<<"tt(2)Hexdecimal=(0010)Binn";
else if(k==3)
cout<<"tt(3)Hexdecimal=(0011)Binn";
else if(k==4)
cout<<"tt(4)Hexdecimal=(0100)Binn";
else if(k==5)
cout<<"tt(5)Hexdecimal=(0101)Binn";
else if(k==6)
cout<<"tt(6)Hexdecimal=(0110)Binn";
else if(k==7)
cout<<"tt(7)Hexdecimal=(0111)Binn";
else if(k==8)
cout<<"tt(8)Hexdecimal=(1000)Binn";
else if(k==9)
cout<<"tt(9)Hexdecimal=(1001)Binn";
else if(k==10)
cout<<"tt(10,A)Hexdecimal=(1010)Binn";
else if(k==11)
cout<<"tt(11,B)Hexdecimal=(1011)Binn";
else if(k==12)
cout<<"tt(12,C)Hexdecimal=(1100)Binn";
else if(k==13)
cout<<"tt(13,D)Hexdecimal=(1101)Binn";
else if(k==14)
cout<<"tt(14,E)Hexdecimal=(1110)Binn";
else if(k==15)
cout<<"tt(15,F)Hexdecimal=(1111)Binn";
else if(k>=16)
cout<<" The Number is not found!........n";
}
else if(n==2)
{
cout<<"please enter any code in Binary.only(4)character n ";
cin>>c;
if(c==0000)
cout<<"tt(0000)Bin = (0)Hex n";
else if(c==0001)
cout<<"tt(0001)Bin = (1)Hex n";
else if(c==0010)
cout<<"tt(0010)Bin = (2)Hex n";
else if(c==0011)
cout<<"tt(0011)Bin = (3)Hex n";
else if(c==0100)
cout<<"tt(0100)Bin = (4)Hex n";
else if(c==0101)
cout<<"tt(0101)Bin = (5)Hex n";
else if(c==0110)
cout<<"tt(0110)Bin = (6)Hex n";
else if(c==0111)
cout<<"tt(0111)Bin = (7)Hex n";
else if(c==1000)
cout<<"tt(1000)Bin = (8)Hex n";
else if(c==1001)
cout<<"tt(1001)Bin = (9)Hex n";
else if(c==1010)
cout<<"tt(1010)Bin = (10)Hex n";
else if(c==1011)
cout<<"tt(1011)Bin = (11)Hex n";
else if(c==1100)
cout<<"tt(1100)Bin = (12)Hex n";
else if(c==1101)
cout<<"tt(1101)Bin = (13)Hex n";
else if(c==1110)
cout<<"tt(1110)Bin = (14)Hex n";
else if(c==1111)
cout<<"tt(1111)Bin = (15)Hex n";
}
else if(n==3)
{
cout<<" please enter the number in Decimal. from(0 to 7)n";
cin>>d;
if(d==0)
cout<<"tt(0)Decimal=(000)Octal n";
else if(d==1)
cout<<"tt(1)Decimal=(001)Octal n";
else if(d==2)
cout<<"tt(2)Decimal=(010)Octal n";
else if(d==3)
cout<<"tt(3)Decimal=(011)Octal n";
else if(d==4)
cout<<"tt(4)Decimal=(100)Octal n";
else if(d==5)
cout<<"tt(5)Decimal=(101)Octal n";
else if(d==6)
cout<<"tt(6)Decimal=(110)Octal n";
else if(d==7)
cout<<"tt(7)Decimal=(111)Octal n";
else if(d>=8)
cout<<" The Number is not found!........n";
}
else if(n==4)
{
cout<<" please enter the code in octal. only(3)character n";
cin>>o;
if(o==000)
cout<<"tt(000)Octal=(0)Decimal n";
else if(o==001)
cout<<"tt(001)Octal=(1)Decimal n";
else if(o==010)
cout<<"tt(010)Octal=(2)Decimal n";
else if(o==011)
cout<<"tt(011)Octal=(3)Decimal n";
else if(o==100)
cout<<"tt(100)Octal=(4)Decimal n";
else if(o==101)
cout<<"tt(101)Octal=(5)Decimal n";
else if(o==110)
cout<<"tt(110)Octal=(6)Decimal n";
else if(o==111)
cout<<"tt(111)Octal=(7)Decimal n";
}
else if(n==5)
{
cout<<"please enter any number in Decimal . from(0 to 15)n";
cin>>s;
if(s==0)
cout<<"tt(0)Decimal = (0000)Binary.ntt(0)Hexdecimal= (000) Octal. n";
else if(s==1)
cout<<"tt(1)Decimal = (0001)Binary.n tt(1)Hexdecimal= (001) Octal. n";
else if(s==2)
cout<<"tt(2)Decimal = (0010)Binary.n tt(2)Hexdecimal= (010) Octal.n";
else if(s==3)
cout<<"tt(3)Decimal = (0011)Binary.n tt(3)Hexdecimal= (011) Octal. n";
else if(s==4)
cout<<"tt(4)Decimal = (0100)Binary.ntt(4)Hexdecimal= (100) Octal. n";
else if(s==5)
cout<<"tt(5)Decimal = (0101)Binary.ntt(5)Hexdecimal= (101) Octal. n";
else if(s==6)
cout<<"tt(6)Decimal = (0110)Binary.ntt(6)Hexdecimal= (110) Octal. n";
else if(s==7)
cout<<"tt(7)Decimal = (0111)Binary.ntt(7)Hexdecimal= (111) Octal. n";
else if(s==8)
cout<<"tt(8)Decimal = (1000)Binary.ntt(8)Hexdecimal= (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==9)
cout<<"tt(9)Decimal = (1001)Binary.ntt(Q)Hexdecimal= (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==10)
cout<<"tt(10)Decimal = (1010)Binary.ntt(A)Hexdecimal = (Q) Octal.nnnQ manes system has not code in this number.n";
else if(s==11)
cout<<"tt(11)Decimal = (1011)Binary.ntt(B)Hexdecimal = (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==12)
cout<<"tt(12)Decimal = (1100)Binary.ntt©Hexdecimal = (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==13)
cout<<"tt(13)Decimal = (1101)Binary.ntt(D)Hexdecimal= (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==14)
cout<<"tt(14)Decimal = (1110)Binary.ntt(E)Hexdecimal= (Q) Octal. nnnQ manes system has not code in this number.n";
else if(s==15)
cout<<"tt(15)Decimal = (1111)Binary.ntt(F)Hexdecimal = (Q) Octal. nnnQ manes system has not code in this number.n";
}
else if(n>=6)
{
cout:(
//عذرا , قمت بتعديل بسيط ليظهر الكود بصورة افضل .