Skip to content

Commit

Permalink
Merge pull request #264 from puji4810/main
Browse files Browse the repository at this point in the history
  • Loading branch information
rsp4jack authored Feb 1, 2024
2 parents 3f315b0 + 3a46176 commit 4e23eca
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/群友提交/第01题/mq日.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#include <algorithm>
#include <vector>
#include <functional>
#include <iostream>
template<typename T,typename IT>
T& operator |(T&& v,const IT& f)
{
for(auto&& x:v)
{
f(x);
}
return v;
}

int main()
{
std::vector v{1, 2, 3};
std::function f{[](const int &i){ std::cout << i << ' '; }};
auto f2 = [](int &i){ i *= i; };
v | f2 | f;
#include <algorithm>
#include <vector>
#include <functional>
#include <iostream>
template<typename T,typename IT>
T& operator |(T&& v,const IT& f)
{
for(auto&& x:v)
{
f(x);
}
return v;
}

int main()
{
std::vector v{1, 2, 3};
std::function f{[](const int &i){ std::cout << i << ' '; }};
auto f2 = [](int &i){ i *= i; };
v | f2 | f;
}
28 changes: 28 additions & 0 deletions src/群友提交/第02题/mq日.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <format>
#include <functional>
#include <iostream>
#include <numbers>
#include <string>
#include <string_view>
using namespace std;

auto operator""_f(const char *s, size_t size)
{
return [=](auto &&...Args)
{
auto t=string_view(s,size);
return vformat(t, make_format_args(Args...));
};
}

int main()
{
std::cout << "乐 :{} *\n"_f(5);
std::cout << "乐 :{0} {0} *\n"_f(5);
std::cout << "乐 :{:b} *\n"_f(0b01010101);
std::cout << "{:*<10}"_f("卢瑟");
std::cout << '\n';
int n{};
std::cin >> n;
std::cout << "π:{:.{}f}\n"_f(std::numbers::pi_v<double>, n);
}

0 comments on commit 4e23eca

Please sign in to comment.