?? 泛性運算問題.cpp
字號:
// 泛性運算問題.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <string>
#include <functional>
#include <vector>
using namespace std;
int main(void)
{
cout<<"Please input filename:";
string filename;
cin>>filename; //測試時輸入的文件名為:yy.txt,其內容為:
//6 8 12 23 34 45 56 89 90 109
if(filename.empty()||!cin){
cout<<"Can not read filename!\n";
return -1;
}
ifstream ff(filename.c_str());
if(!ff){
cout<<"Can not open file of "<<filename<<endl;
return -2;
}
istream_iterator<int> input(ff);
istream_iterator<int> end_of_stream;
vector<int> ivec;
copy(input,end_of_stream,inserter(ivec,ivec.begin()));
cout<<ivec[0]<<" "<<ivec[1]; //此處輸出結果為6 8
cout<<endl<<endl;
ostream_iterator<int> out(cout," ");
copy(input,end_of_stream,out); //但是為什么這個地方輸出的結果是6,而不是6 8 12 23 34 45 56 89 90 109
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -