forked from vroon33/RISC-V-Processor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert.cpp
More file actions
40 lines (31 loc) · 788 Bytes
/
convert.cpp
File metadata and controls
40 lines (31 loc) · 788 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
35
36
37
38
39
40
// Converts hexadecimal to decimal
// Input: number of test cases, followed by hexadecimal numbers
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
unsigned int num;
cin >> num;
cout << setw(2) << setfill('0') << hex << uppercase << num << endl;
}
return 0;
}
// Converts decimal to hexadecimal
// Input: number of test cases, followed by decimal numbers
// #include <iostream>
// #include <iomanip>
// using namespace std;
// int main() {
// int t;
// cin >> t;
// while (t--) {
// string hexNum;
// cin >> hexNum;
// unsigned int num = stoi(hexNum, nullptr, 16);
// cout << num << endl;
// }
// return 0;
// }