bdfz_2024_summer/day3/afternoon/operator.cpp

32 lines
696 B
C++
Raw Normal View History

2024-08-04 06:40:17 +00:00
#include <bits/stdc++.h>
2024-08-04 07:16:08 +00:00
#define uint unsigned int
using std::cout,std::vector,std::endl;
template<typename T>
std::ostream& operator<<(std::ostream& os,vector<T> &v){
os<<"vector<?> [";
for(size_t i=0;i<v.size();i++){
os<<v[i]<<(i!=v.size()-1?",":"]\n");
}
return os;
}
2024-08-04 06:40:17 +00:00
std::ostream& operator<<(std::ostream& os,vector<int> &v){
os<<"vector<int> [";
for(size_t i=0;i<v.size();i++){
os<<v[i]<<(i!=v.size()-1?",":"]\n");
}
return os;
}
int main(){
2024-08-04 07:16:08 +00:00
vector<int> v(10);
for(uint i=0;i<v.size();i++){
v[i]=i;
}
2024-08-04 06:40:17 +00:00
cout<<v<<endl;
2024-08-04 07:16:08 +00:00
vector<std::string> vs;
vs.push_back("123");
vs.push_back("1024");
cout<<vs<<endl;
2024-08-04 06:40:17 +00:00
}