优秀的代码
vector
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int x;
void go(){while(1)v.push_back(x++);}
int main(){
go();
return 0;
}时间戳
#include<bits/stdc++.h>
using namespace std;
int main(){
long long st,ed,sc;
sc=10;//秒数
st=time(0);
while(1){
ed=time(0);
if(ed-st==sc){
puts("go\n");//do sth
break;
}
}
return 0;
}综合应用 :
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int x;
void go(){while(1)v.push_back(x++);}
int main(){
long long st,ed,sc;//秒数
sc=10;
st=time(0);
while(1){
ed=time(0);
if(ed-st>=sc){
puts("go\n");//do sth
go();
break;
}
}
return 0;
}