当前位置: 首页>>代码示例>>C++>>正文


C++ ifstream::rdbuf方法代码示例

本文整理汇总了C++中ifstream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ifstream::rdbuf方法的具体用法?C++ ifstream::rdbuf怎么用?C++ ifstream::rdbuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ifstream的用法示例。


在下文中一共展示了ifstream::rdbuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:ak795,项目名称:acm,代码行数:28,代码来源:2.cpp

示例2: 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;
}
开发者ID:ak795,项目名称:acm,代码行数:31,代码来源:2.cpp

示例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< 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;

}
开发者ID:AphroditeSpartacus,项目名称:arena,代码行数:34,代码来源:1.cpp

示例4: 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;
}
开发者ID:ak795,项目名称:acm,代码行数:34,代码来源:2.cpp

示例5: main

int main(int argn, char const* argv[]) {
    cin.exceptions(ios_base::badbit | ios_base::failbit);
    cout.setf( ios::fixed, ios::floatfield );
    cout.precision(1);

    if (argn > 1) {
      static ifstream ifs{argv[1]};
      cin.rdbuf(ifs.rdbuf());
    }

    std::vector<int> samples;
    {
        int n = 0;
        cin >> n;
           samples.reserve(n);
        while(n-- > 0) {
            int i = 0;
            cin >> i;
            samples.push_back(i);
        }
    }

    auto result = solution(samples);
    cout << result << "\n";

    return 0;
}
开发者ID:rafald,项目名称:cpp_sandbox,代码行数:27,代码来源:missing_integer.cpp

示例6:

	XML_File(string s){
		inFile.open(s, fstream::in);
		ostringstream ss;
		ss << inFile.rdbuf();
		content = ss.str();
		inFile.close();
	}
开发者ID:Unethical,项目名称:cplusplus,代码行数:7,代码来源:Lab4.cpp

示例7: 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;
}
开发者ID:ak795,项目名称:acm,代码行数:32,代码来源:1.cpp

示例8: testErrorCounter

int CounterErrorTester::testErrorCounter(ifstream& aInStream, CounterError& bProcessor, const char* cFilename)
{
	aInStream.open(cFilename);		//открываем файл
	cin.rdbuf(aInStream.rdbuf());		//получаем буфер
	int result = bProcessor.CountErorrs();  //вызываем счетчик ошибок
	aInStream.close();			//закрываем файл
	return result;				//отправляем результат
}						
开发者ID:5821gkv,项目名称:lipo-sapr-lab2,代码行数:8,代码来源:CounterErrorTester.cpp

示例9: 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
}
开发者ID:hujiewang,项目名称:Programming-Contests,代码行数:8,代码来源:uva10141.cpp

示例10: se

bool
STIL::determineEOL(ifstream &stilFile)
{
    CERR_STIL_DEBUG << "detEOL() called" << endl;

    if (stilFile.fail())
    {
        CERR_STIL_DEBUG << "detEOL() open failed" << endl;
        return false;
    }

    stilFile.seekg(0);

    STIL_EOL = '\0';
    STIL_EOL2 = '\0';

    // Determine what the EOL character is
    // (it can be different from OS to OS).
    istream::sentry se(stilFile, true);
    if (se)
    {
        streambuf *sb = stilFile.rdbuf();

        const int eof = char_traits<char>::eof();

        while (sb->sgetc() != eof)
        {
            const int c = sb->sbumpc();
            if ((c == '\n') || (c == '\r'))
            {
                STIL_EOL = c;

                if (c == '\r')
                {
                    if (sb->sgetc() == '\n')
                        STIL_EOL2 = '\n';
                }
                break;
            }
        }
    }

    if (STIL_EOL == '\0')
    {
        // Something is wrong - no EOL-like char was found.
        CERR_STIL_DEBUG << "detEOL() no EOL found" << endl;
        return false;
    }

    CERR_STIL_DEBUG << "detEOL() EOL1=0x" << hex << static_cast<int>(STIL_EOL) << " EOL2=0x" << hex << static_cast<int>(STIL_EOL2) << dec << endl;

    return true;
}
开发者ID:kode54,项目名称:sidplay-residfp,代码行数:53,代码来源:stil.cpp

示例11: 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;
}
开发者ID:paohui817,项目名称:arena,代码行数:14,代码来源:2.cpp

示例12: decode_morse

//the parser for reading from file
string Morse::decode_morse(ifstream& fin)
{
	if (!fin.good()){
		return "ERROR: The file cannot be opened";
	}
	stringstream buffer;
	buffer << fin.rdbuf();
	string code_to_decipher, decoded = "";

	while (buffer >> code_to_decipher){
		decoded += " " + decoding(root, code_to_decipher);
	}

	return decoded;
}
开发者ID:ChrisWphoto,项目名称:D303-Project3,代码行数:16,代码来源:Morse.cpp

示例13: main

int main()
{
#ifdef DEBUG
  cin.rdbuf(fin.rdbuf());  
#endif

  int n;
  cin>>n;
  vector<int> v(n);
  for (int i=0; i<n; ++i) cin>>v[i];
  sort((v).begin(), (v).end());
  long long sum=0, res=0;
  for (long long i=0; i<n; ++i) res+=v[i]*i-sum, sum+=v[i];
  cout<<res*2<<endl;
}
开发者ID:ak795,项目名称:acm,代码行数:15,代码来源:2.cpp

示例14: 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;
}
开发者ID:ak795,项目名称:acm,代码行数:15,代码来源:1.cpp

示例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;
    dfs(n, 1, 2);
    dfs(n, 0, 0);
}
开发者ID:ak795,项目名称:acm,代码行数:15,代码来源:2.cpp


注:本文中的ifstream::rdbuf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。