Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/10/2012, 08:35
sonrasiel
 
Fecha de Ingreso: septiembre-2012
Mensajes: 29
Antigüedad: 11 años, 7 meses
Puntos: 0
como es eso, de que no existe el fichero o directorio?

hola tengo lios con esta funcion alguna cosa de una librería no entiendo muy bien ya antes había puesto funciones fuera del main y no me habia pasado esto. En resumen este programa debería darme el tamaño del numero que introduzca el usuario con un numero entero pero no pase ni del main.
Código C++:
Ver original
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. using namespace std;
  6. float tamaño(float){
  7.  
  8. float a;
  9. if(-1>a>1){//divide el numero para contar las veces que el numero es dividido
  10.     tamaño (a/10);
  11.     return a;
  12. }}
  13. int main() {
  14. float;num tam;
  15. cout<< "introdusca el numero"; 
  16. cin>>num;
  17. tam=1;
  18. tam=tam+1;//cuenta las veces que se divide el numero
  19. num=tamaño(num);//llama a la funcion tamaño a y evalua el numero;
  20. cout<<"el tamaño es"<<tam;
  21. system("pause");
  22.     return 0;
  23. }
  24. }

errores

g++.exe g++.exe C:\Users\Fredy\Downloads\g++.exe tama±o.cpp: No such file or directory.
fata C:\Users\Fredy\Downloads\g++.exe [Error] no input files
C:\Users\Fredy\Downloads\Makefile.win [Error] [tamaño.o] Error 1 (if this is the only error: please check your library includes).

aquí otro programa que intente hacer con el mismo problema.

Código C++:
Ver original
  1. #include <iostream>
  2.  
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4.  
  5. int contador(float){
  6.     float a;
  7.     a=a+1;
  8. }
  9. int main() {
  10.     float tam,b,;
  11.     cin>>tam,
  12.     if(tam>1){
  13.    
  14.     while (-1>tam>1){//para los numeros enteros
  15.         tam=tam/10;
  16.         b=contador(a);
  17.         cout>>b;
  18.     }}
  19.         else{
  20.             while(-1<tam<1)//para decimales.
  21.             tam=tam*10;
  22.             b=contador(a);
  23.             cout>>b;
  24.            
  25.         }
  26.     })
  27.     return 0;
  28. }
  29. }

por poner un ejemplo con esta función no me pone trabas.
Código C++:
Ver original
  1. #include <iostream>
  2.  #include <cstdlib>
  3. using namespace std;
  4.  
  5. int compuesto(float,float,float);
  6.  
  7. int main() {
  8.   float a,b,c;
  9.  
  10.   cout << "introduzca litros de A: ";
  11.   cin >> a;
  12.   cout << endl << "introduzca litros de B: ";
  13.   cin >> b;
  14.   cout << endl << "introduzca litros de C: ";
  15.   cin >> c;
  16.   compuesto(a,b,c);
  17. }
  18.  
  19. int compuesto(float a, float b, float c) {
  20.   float comp = a+b+c;
  21.   cout << endl;
  22.   cout << "Compuesto resultante: " << comp << " litros" << endl;
  23.   cout.precision(1);
  24.   cout << fixed;
  25.   cout << "Proporcion de A: " << a / comp * 100 << "%" << endl;
  26.   cout << "Proporcion de B: " << b / comp * 100 << "%" << endl;
  27.   cout << "Proporcion de C: " << c / comp * 100 << "%" << endl;
  28.   system ("PAUSE");
  29.   return 0;
  30. }

errores
g++.exe g++.exe C:\Users\Fredy\Downloads\g++.exe tama±o.cpp: No such file or directory.
fata C:\Users\Fredy\Downloads\g++.exe [Error] no input files
C:\Users\Fredy\Downloads\Makefile.win [Error] [tamaño.o] Error 1 (if this is the only error: please check your library includes).

nisiquiera puedo saber si hace lo que debería hacer :S, ya de pasito si no compila me podrían indicar por que no lo haría por favor?, perdón por el abuso. gracias


Después de luchar un poco use otro compilador logre compilar el segundo programa pero me ha arrojado un montón de errores :S aquí esta la lista.


SinNombre3.cpp: In function `int contador(float)':
SinNombre3.cpp:7: error: declaration of 'float a' shadows a parameter

SinNombre3.cpp: In function `int main()':
SinNombre3.cpp:17: error: `a' undeclared (first use this function)

SinNombre3.cpp:17: error: (Each undeclared identifier is reported only once for each function it appears in.)

SinNombre3.cpp:18: error: no match for 'operator>>' in 'std::cout >> b'

SinNombre3.cpp:23: error: expected primary-expression before "float"

SinNombre3.cpp:24: error: no match for 'operator>>' in 'std::cout >> b'

SinNombre3.cpp: At global scope:
SinNombre3.cpp:27: error: expected declaration before '}' token

make.exe: *** [SinNombre3.o] Error 1

Última edición por sonrasiel; 03/10/2012 a las 10:49 Razón: nuevos errores