44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
|
#include <iostream>
|
||
|
#include <iomanip>
|
||
|
|
||
|
int main() {
|
||
|
int input = 0;
|
||
|
|
||
|
std::cout << "Give me an Integer in hex: ";
|
||
|
|
||
|
std::cin >> std::hex >> input ;
|
||
|
|
||
|
std::cout << "Dec: " << input << std::endl;
|
||
|
|
||
|
std::cout << "Hex: " ;
|
||
|
std::cout << std::hex << input << std::endl;
|
||
|
|
||
|
std::cout << "Octal: " ;
|
||
|
std::cout << std::oct << input << std::endl;
|
||
|
|
||
|
|
||
|
float f1, f2, f3 ;
|
||
|
std::cout << "Give me three floats: " << std::endl;
|
||
|
std::cout << "f1: " ;
|
||
|
std::cin >> f1 ;
|
||
|
|
||
|
std::cout << "f2: " ;
|
||
|
std::cin >> f2 ;
|
||
|
|
||
|
std::cout << "f3: " ;
|
||
|
std::cin >> f3 ;
|
||
|
|
||
|
std::cout << "The following floats were given: " << std::endl;
|
||
|
std::cout << std::scientific << f1 << " " << f2 << " " << f3 << std::endl;
|
||
|
|
||
|
|
||
|
std::cout << "That is 20 chars columns per float: " << std::endl;
|
||
|
std::cout << std::setw(20) << "ValueA" << " " << std::setw(20) << "ValueB" << " "<< std::setw(20) << "ValueC" << std::endl;
|
||
|
std::cout << std::setfill('-') << std::setw(3*20 + 2 + 1) << " " << std::endl ;
|
||
|
std::cout << std::setfill(' ') << std::setw(20) << std::scientific << f1 << " " << std::setw(20) << f2 << " "<< std::setw(20) << f3 << std::endl;
|
||
|
|
||
|
|
||
|
std::cout << "With 3 digit precision: " << std::endl;
|
||
|
std::cout << std::left << std::setprecision(3) << std::scientific << f1 << " " << f2 << " " << f3 << std::endl;
|
||
|
}
|