Oppure

Loading
31/01/09 14:24
sweetema
ciao!!!!!!!!ho un problemino....vorrei scrivere un programma ke trasformi i numeri in base binaria in numeri in base decimale!!!ho scrtt il codice ma nn parte...grzie in anticipo baci
#include<iostream.h>
#include<stdlib.h>
#include<cmath>

int a[5];
int i;
int total;


int main()
{
	cout<<"QUESTO PROGRAMMA CONVERTE I NUMERI DA BASE BINARIA A BASE DECIMALE\n\n\n";
	cout<<"INSERIRE IL NUMERO IN BASE BINARIA DI MAX 5 CIFRE\n";
	cin>>a[i];

	for(int j=0;j<5;j++)
	{
      a[j]*=pow(2,j);
      total+=a[j];
    }

	cout<<"il numero in base decimale è "<<total;

	return 0;

}
8-|
aaa
31/01/09 15:16
theprogrammer
Esempio di codice corretto

#include <iostream> 
#include <cmath>

using namespace std;

int main() 
{
	int a[5]; 
	int total=0; 

    cout<<"QUESTO PROGRAMMA CONVERTE I NUMERI DA BASE BINARIA A BASE DECIMALE\n\n\n"; 
    cout<<"INSERIRE IL NUMERO IN BASE BINARIA DI 5 CIFRE (dal bit 0 al bit 4)\n"; 

	for(int i=0;i<5;i++) 
		cin>>a[i]; 

    for(int j=0;j<5;j++) 
    { 
      a[j] *= (int)pow(2,j); 
      total+=a[j]; 
    } 

    cout << "il numero in base decimale è " << total << endl; 

    return 0; 
} 
aaa
31/01/09 17:09
sweetema
...scusami...continua a non eseguirlo..bha8-|
aaa
31/01/09 17:21
theprogrammer
In che senso? Che compilatore usi?

Cosa fai per eseguirlo?
aaa
31/01/09 17:25
sweetema
uso eclipse!!!!nel senso ke mi da errore e non mi dà l'eseguibile!!!:d
aaa
31/01/09 17:30
theprogrammer
Con Windows? Linux?

Quale errore?
aaa
31/01/09 18:16
sweetema
windows!!!!mi dice "call of overloaded 'pow(int,int&;)'is ambiguous"!!!!scusami ma sn una new entry in materia...:-|
aaa
31/01/09 18:54
theprogrammer
Prova con

a[j] *= (int)pow(2.0,(double)j);
aaa