[ Foro de C++ ]

como poner los decimales correctamente?

22-Feb-2024 02:06
Invitado (DILAN)
0 Respuestas

#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
   double exa = 1E18;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<< setw(20)<<"Decimal"<<"|"<<setw(15)<<"Standard form"<<"|"<<setw(8)<<"prefex"<<"|"<<setw(5)<<"Abbreviation"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<exa<<"|"<<setw(8)<<"exa"<<"|"<<setw(10)<<"E"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E15<<"|"<<setw(8)<<"peta"<<"|"<<setw(10)<<"P"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E12<<"|"<<setw(8)<<"tera"<<"|"<<setw(10)<<"T"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E9<<"|"<<setw(8)<<"giga"<<"|"<<setw(10)<<"G"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E6<<"|"<<setw(8)<<"mega"<<"|"<<setw(10)<<"M"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E3<<"|"<<setw(8)<<"kilo"<<"|"<<setw(10)<<"k"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E2<<"|"<<setw(8)<<"hecto"<<"|"<<setw(10)<<"h"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E1<<"|"<<setw(8)<<"deca"<<"|"<<setw(10)<<"da"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1<<"|"<<setw(8)<<"deci"<<"|"<<setw(10)<<"d"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-1<<"|"<<setw(8)<<"centi"<<"|"<<setw(10)<<"c"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-3<<"|"<<setw(8)<<"milli"<<"|"<<setw(10)<<"m"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-6<<"|"<<setw(8)<<"micro"<<"|"<<setw(10)<<"?"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-9<<"|"<<setw(8)<<"nano"<<"|"<<setw(10)<<"n"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-12<<"|"<<setw(8)<<"pico"<<"|"<<setw(10)<<"p"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<"1E-15"<<"|"<<setw(8)<<"femto"<<"|"<<setw(10)<<"f"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<"1E-18"<<"|"<<setw(8)<<"atto"<<"|"<<setw(10)<<"a"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;


   return 0;

}




(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)