本文整理汇总了C++中ofstream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ofstream::rdbuf方法的具体用法?C++ ofstream::rdbuf怎么用?C++ ofstream::rdbuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofstream
的用法示例。
在下文中一共展示了ofstream::rdbuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
time_t timer;
struct tm *ptm;
time(&timer);
ptm = localtime(&timer);
startClock = clock();
logEnabled = false;
stringstream preLog;
clogBack = clog.rdbuf(logStream.rdbuf());
preLog << "\n\n-------------------\n Start program " << ptm->tm_mday << "." << ptm->tm_mon + 1 << "." << ptm->tm_year + 1900
<< " " << ptm->tm_hour << ":" << ptm->tm_min << ":" << ptm->tm_sec << "\n--------------" << endl;
cerrBack = cerr.rdbuf(errStream.rdbuf());
cerr << "\n\n-------------------\n Start program " << ptm->tm_mday << "." << ptm->tm_mon+1 << "." << ptm->tm_year + 1900
<< " " << ptm->tm_hour << ":" << ptm->tm_min << ":" << ptm->tm_sec << endl;
preLog << "\nProgram launched with arguments:\n";
cout << "\nProgram launched with arguments:\n";
for(int ii = 0; ii < argc; ii++)
{
preLog << (argv[ii]) << " ";
cout << (argv[ii]) << " ";
}
int result = _main(argc, argv, &preLog);
end();
return result;
}
示例2: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
int a[3], b[3];
int p[3][3];
for (int i=0; i<3; ++i) cin>>a[i];
for (int i=0; i<3; ++i) for (int j=0; j<3; ++j) cin>>p[i][j];
int m=INT_MAX, r1=0, r2=0, r3=0, c;
for (int k1=0; k1<100; ++k1)
for (int k2=0; k2<100; ++k2)
for (int k3=0; k3<100; ++k3) {
b[0]=k1*p[0][0]+k2*p[1][0]+k3*p[2][0];
b[1]=k1*p[0][1]+k2*p[1][1]+k3*p[2][1];
b[2]=k1*p[0][2]+k2*p[1][2]+k3*p[2][2];
// cout<<k1<<" "<<k2<<" "<<k3<<" ";
// print(a, 3); print(b, 3);
int tmp;
if ((tmp=check(a, b, 3))!=0) {
int aux=k1+k2+k3;
if (aux<m) { m=aux, r1=k1, r2=k2, r3=k3; c=tmp; }
}
}
if (m==INT_MAX) cout<<"NONE"<<endl;
else cout<<r1<<" "<<r2<<" "<<r3<<" "<<c<<endl;
}
示例3: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
vector<int> res(7);
int cur = (1 + 13 - 1) % 7, next = cur;
for (int i = 0; i < n; ++i) {
int leap = leap_year(1900 + i);
for (int j = 0; j < 12; ++j) {
cur = next;
++res[cur];
next = (cur + month[leap][j]) % 7;
}
}
for (int i = 0; i < 7; ++i) {
if (i) cout << " ";
cout << res[(6 + i) % 7];
}
cout << endl;
}
示例4: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
/////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
vector< pair<int, int> > v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i].first >> v[i].second;
}
sort((v).begin(), (v).end());
int start = v[0].first, end = v[0].second;
int x = end - start, y = 0;
for (int i = 1; i < n; ++i) {
if (v[i].first > end) {
y = max(y, v[i].first - end);
start = v[i].first;
end = v[i].second;
} else if (v[i].second > end) {
end = v[i].second;
}
x = max(x, end - start);
}
cout << x << " " << y << endl;
}
示例5: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
int min_area = INT_MAX;
set< pair<int, int> > res;
vector< pair<int, int> > v(4);
for (int i = 0; i < 4; ++i)
cin >> v[i].first >> v[i].second;
for (int p = 0; p < (1 << 4); ++p) {
vector< pair<int, int> > v2 = v;
for (int q = 0; q < 4; ++q) {
if (p & (1 << q))
swap(v2[q].first, v2[q].second);
}
int a[4] = {0, 1, 2, 3};
do {
vector< pair<int, int> > aux(4);
for (int i = 0; i < 4; ++i)
aux[i] = v2[a[i]];
func(aux, min_area, res);
} while (next_permutation(a, a + 4));
}
cout << min_area << endl;
for (__typeof((res).begin()) i = (res).begin(); i != (res).end(); ++i)
cout << i->first << " " << i->second << endl;
}
示例6: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
vector< pair<int, int> > v(n);
for (int i = 0; i < n; ++i)
cin >> v[i].first >> v[i].second;
sort((v).begin(), (v).end());
int start = v[0].first, end = v[0].second;
int continuous_time = 0, idle_time = 0;
for (int i = 0; i < n; ++i) {
if (v[i].first <= end) {
end = max(end, v[i].second);
continuous_time = max(continuous_time, end - start);
} else {
idle_time = max(idle_time, v[i].first - end);
start = v[i].first;
end = v[i].second;
continuous_time = max(continuous_time, end - start);
}
}
cout << continuous_time << " " << idle_time << endl;
}
示例7: redirect
void redirect(){
#ifdef DEBUG
std::streambuf *cinbuf = std::cin.rdbuf();
std::cin.rdbuf(fin.rdbuf());
std::streambuf *coutbuf = std::cout.rdbuf();
std::cout.rdbuf(fout.rdbuf());
#endif
}
示例8: Assign
//Assign
void OutputBuffer::Assign(ofstream &file, size_t size) {
Destroy();
Size = size;
//If it fails, a bad_alloc exception will be thrown and will not be caught. You should be able to recover and use
//the default buffer
Buffer = new char[size];
file.rdbuf()->pubsetbuf(Buffer, size);
}
示例9: keepTestHorizon
bool keepTestHorizon( FbxAnimCurve* curve, FbxAnimCurveKey prevkey, FbxAnimCurveKey currkey, FbxAnimCurveKey nextkey)
{
FbxTime prevt = prevkey.GetTime();
FbxTime currt = currkey.GetTime();
FbxTime nextt = nextkey.GetTime();
bool needit = false;
float prevEv;
FbxLongLong tmpll = (currt - prevt).GetMilliSeconds() / 3;
FbxTime termt;
float tmpfs[6] = { -1, };
FbxTime times[6];
for (int termi = 0; termi < 3; termi++)
{
termt.SetMilliSeconds(tmpll*termi);
times[termi] = prevt + termt;
}
tmpll = (nextt - currt).GetMilliSeconds() / 3;
for (int termi = 0; termi < 3; termi++)
{
termt.SetMilliSeconds(tmpll*termi);
times[3 + termi] = currt + termt;
}
output2 << setw(20 + output2.rdbuf()->in_avail() - 4096) << "timee : ";
for (int i = 0; i < 6; i++)
{
output2 << setw(10) << setiosflags(ios::fixed) << setprecision(3) << (times[i]).GetSecondDouble() << "\t";
tmpfs[i] = curve->Evaluate(times[i]);
}
output2 << endl << setw(20) << "value : ";
for (int i = 0; i < 6; i++)
{
output2 << setw(10) << setiosflags(ios::fixed) << setprecision(3) << tmpfs[i] << "\t";
}
for (int i = 1; i<6;i++)
if (abs(tmpfs[i] - tmpfs[i-1]) > comp_level_horizon)
{
output2 << "keepinHorizon at : " << i << endl;
return true;
}
output2 << endl;
return false;
}
示例10: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
/////////////////////////////////////////////////////////////////////////
int a, b;
cin >> a >> b;
cout << a + b << endl;
}
示例11: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
string in, pre, res;
cin>>in>>pre;
res=func(in, pre);
cout<<res<<endl;
}
示例12: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
//////////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
dfs(n, 1, 2);
dfs(n, 0, 0);
}
示例13: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
////////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
for (int i = 0; i < n; ++i)
cin >> x[i] >> y[i];
vector<string> g(n);
for (int i = 0; i < n; ++i)
cin >> g[i];
vector<vector<double> > dist(n, vector<double>(n, MAX));
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
if (g[i][j] == '1')
dist[i][j] = dist[j][i] = euclidean_distance(i, j);
for (int k = 0; k < n; ++k)
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
double aux = 0;
vector<double> diameter(n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j)
if (i != j && dist[i][j] < MAX)
diameter[i] = max(diameter[i], dist[i][j]);
aux = max(aux, diameter[i]);
}
double res = MAX;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
if (i != j && dist[i][j] == MAX)
res = max(min(res, euclidean_distance(i, j) + diameter[i] + diameter[j]), aux);
cout << setiosflags(ios::fixed) << setprecision(6);
cout << res << endl;
}
示例14: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
/////////////////////////////////////////////////////////////////////////
cin >> sum >> left_top;
create_prime();
g[0][0] = row_sum[0][0] = column_sum[0][0] = left_top;
found = false;
dfs(0, 1);
if (!found)
cout << "NONE" << endl;
}
示例15: main
int main()
{
cin.rdbuf(fin.rdbuf());
cout.rdbuf(fout.rdbuf());
#ifdef DEBUG
cin.rdbuf(cin_buf);
cout.rdbuf(cout_buf);
#endif
////////////////////////////////////////////////////////////////////////////
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; ++i) {
cin >> v[i];
--v[i];
}
vector<int> cnt(3);
for (int i = 0; i < n; ++i)
++cnt[v[i]];
vector< vector<int> > place(3, vector<int>(3));
for (int i = 0; i < n; ++i)
if (i < cnt[0])
++place[0][v[i]];
else if (i < cnt[0] + cnt[1])
++place[1][v[i]];
else
++place[2][v[i]];
int res = 0;
int aux = min(place[0][1], place[1][0]);
res += aux;
place[0][1] -= aux;
aux = min(place[0][2], place[2][0]);
res += aux;
place[0][2] -= aux;
aux = min(place[1][2], place[2][1]);
res += aux;
aux = max(place[0][1], place[0][2]);
res += 2 * aux;
cout << res << endl;
}