-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathself.cpp
More file actions
56 lines (38 loc) · 1.2 KB
/
Copy pathself.cpp
File metadata and controls
56 lines (38 loc) · 1.2 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* import std;
int main(){
int answer {42};
std::println("The answer to life, the universe, and everything is {}." answer);
return 0;
}
gcc++23 above not mine */
#include <iostream>
int main() {
int answer{42};
std::cout << "The answer to life, the universe, and everything is " << answer << std::endl;
std::cout << std::format("The answer to life, the universe, and everything is {}." , answer) << std::endl; // c++20 above
return 0;
}
/* import std;
int main(){
int answer {42};
std::println("The answer to {} is {:!^12b}", "the ultimate question", answer);
return 0;
}
gcc++23 above not mine */
/*
#include <iostream>
#include <string>
#include <bitset>
int main() {
int answer = 42;
std::string bin = std::bitset<32>(answer).to_string();
bin.erase(0, bin.find_first_not_of('0'));
int width = 12;
int pad = width - bin.size();
int left = pad / 2;
int right = pad - left;
std::string formatted = std::string(left, '!') + bin + std::string(right, '!');
std::cout << "The answer to " << "the ultimate question" << " is "<< formatted << "\n";
return 0;
}
*/