ProgramAlgTrain/20240907/testTpl/testTpl.cpp

54 lines
1.1 KiB
C++
Raw Normal View History

2024-09-15 09:35:54 +00:00
#include <cmath>
#include<iostream>
#include <numeric>
#include <sstream>
#include <vector>
typedef unsigned int u8;
std::ostream& operator<<(std::ostream &os,const std::vector<int> &v){
os<<"vector { ";
for(int i=0;(u8)i<v.size()-1;i++){
os<<v[i]<<" ,";
}
os<<v[v.size()-1]<<" }";
return os;
}
template<typename ...Args>
2024-09-17 10:55:15 +00:00
void zprint(const Args& ...args){
2024-09-15 09:35:54 +00:00
((std::cout<<args),...);
}
template<typename ...Args>
2024-09-17 10:55:15 +00:00
void zprintln(const Args& ...args){
2024-09-15 09:35:54 +00:00
std::stringstream ss;
((ss<<args<<" "),...);
ss<<"\n";
2024-09-17 10:55:15 +00:00
zprint(ss.str());
2024-09-15 09:35:54 +00:00
}
#define NAME_VALUE(v)#v,":",(v)
int main(){
2024-09-17 10:55:15 +00:00
zprintln("Hello,World!","-by","Zengtudor");
zprintln("End");
zprintln(NAME_VALUE(std::pow(2,10)));
zprintln(NAME_VALUE((int)0x7FFFFFFF));
2024-09-15 09:35:54 +00:00
std::vector<int> v(10);
v[0]=1;
for(int i=1;(u8)i<v.size();i++){
v[i]=(v[i-1]*3+2)%49;
}
2024-09-17 10:55:15 +00:00
zprintln(NAME_VALUE(v));
zprintln(NAME_VALUE(std::pow(3, 8)));
zprintln(NAME_VALUE(std::gcd(41184, 65208)));
2024-09-15 09:35:54 +00:00
for(int i=1;i<=1e4;i++){
2024-09-17 10:55:15 +00:00
zprint(i,",");
2024-09-15 09:35:54 +00:00
}
2024-09-17 10:55:15 +00:00
zprint("\n");
2024-09-15 09:35:54 +00:00
}