|
#include <cstdlib>
#include <conio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
void gotoxy(int x,int y);
int main(void)
{
system("cls");
system("color f0");
long int bit=0, s=0,scelta;
cout<<"Inserisci numero binario"<<endl;
do
{
do bit = getch(); while(bit!=48 && bit!=49 && bit!=13);
if(bit!=13)
{
cout<<bit-48;
s = (s*2) + (bit-48);
}
}while(bit!=13);
gotoxy(5,5); cout<<"In Decimale: "<<s<<endl<<endl;
cout<<" 1) Altra conversione\n";
cout<<" 2) Esci";
scelta = getch();
if(scelta == 49) main();
if(scelta == 50) exit(0);
return 0;
}
void gotoxy(int x,int y)
{
COORD coor;
HANDLE hOutput;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
coor.X = x;
coor.Y = y;
SetConsoleCursorPosition(hOutput,coor);
}
|
|