- 论坛徽章:
- 0
|
I am sure it's the problem of the platform, maybe configration of VC.
Because it's ok under linux and GCC.
#include <iostream>;
#include <algorithm>;
#include <vector>;
#include <iterator>;
int main()
{
int ia[10]={ 34,91,83,56,29,93,56,12,88,72 };
vector<int>; vec(ia,ia+10);
vector<int>;::iterator presult;
presult=min_element(vec.begin(),vec.end());
cout << "The minimum is " << *presult << endl;
cout << "The sequence number is " << presult-vec.begin() << endl;
}
********************************************
Under VC&W2K
E:\CPP\72\72.cpp(13) : error C2065: 'vector' : undeclared identifier
E:\CPP\72\72.cpp(13) : error C2062: type 'int' unexpected
E:\CPP\72\72.cpp(15) : error C2062: type 'int' unexpected
E:\CPP\72\72.cpp(15) : error C2039: 'iterator' : is not a member of '`global
namespace''
E:\CPP\72\72.cpp(16) : error C2065: 'presult' : undeclared identifier
E:\CPP\72\72.cpp(16) : error C2065: 'min_element' : undeclared identifier
E:\CPP\72\72.cpp(16) : error C2065: 'vec' : undeclared identifier
E:\CPP\72\72.cpp(16) : error C2228: left of '.begin' must have
class/struct/union type
E:\CPP\72\72.cpp(16) : error C2228: left of '.end' must have
class/struct/union type
E:\CPP\72\72.cpp(17) : error C2065: 'cout' : undeclared identifier
E:\CPP\72\72.cpp(17) : error C2100: illegal indirection
E:\CPP\72\72.cpp(17) : error C2065: 'endl' : undeclared identifier
E:\CPP\72\72.cpp(17) : warning C4552: '<<' : operator has no effect;
expected operator with side-effect
E:\CPP\72\72.cpp(19) : warning C4508: 'main' : function should return a
value; 'void' return type assumed
Error executing cl.exe.
72.exe - 12 error(s), 2 warning(s)
*********************************************
Under linux and GCC, the output is:
The minimun number is 12
The sequence number of the min is 8 |
|