-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathPrint Pretty.cpp
More file actions
34 lines (32 loc) · 979 Bytes
/
Copy pathPrint Pretty.cpp
File metadata and controls
34 lines (32 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int len=0;
double AA=A;
while(AA>=1)
{
len+=1;
AA/=16;
}
len+=2;
int length=0;
double BB=B;
if(B<0)
BB=B*(-1);
while(BB>=1)
{
length+=1;
BB/=10;
}
length=15-length-3;
/* Enter your code here */
cout << showbase; // fill with 0s
cout << hex << nouppercase << setw(len) << (long long int)A <<endl;
cout.unsetf ( std::ios::floatfield );
cout<< fixed << setprecision(2);
cout << showbase // show the 0x prefix
<< internal // fill between the prefix and the number
<< setfill('_'); // fill with 0s
if(B>0)
cout << setw(length) << "+" << B << endl;
else
cout << setw(length) << "-" << (-1)*B << endl;
cout.precision(9);
cout << scientific << uppercase << C <<endl;