CPP 무료 덤프문제 온라인 액세스

시험코드:CPP
시험이름:C++ Certified Professional Programmer
인증사:C++ Institute
무료 덤프 문항수:230
업로드 날짜:2026-01-10
평점
100%

문제 1

What happens when you attempt to compile and run the following code?
# include <iostream>
# include <fstream>
# include <string>
# include <list>
# include <algorithm>
# include <iomanip>
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
operator int() const { return val; };};
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) {out<<setw(3)<<hex<<val; } };
int main () {
int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
fstream f("test.out", ios::trunc|ios::out);
list<B> l(t, t+10);
for_each(l.begin(), l.end(), Out<B>(f));
f.close();
f.open("test.out");
for( ; f.good() ; ) {
B i;
f>>i;
cout<<i<<" ";
}
f.close();
return 0;
}

문제 2

What happens when you attempt to compile and run the following code?
# include <deque>
# include <iostream>
# include <algorithm>
using namespace std;
class B { int val;
public:
B(int v):val(v){}
int getV() const {return val;} bool operator < (const B & v) const { return val<v.val;} }; ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;} template<class T>struct Out {
ostream & out; Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
int main() {
int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20};
deque<B> d1(t, t+10);
sort(d1.begin(), d1.end());
pair<deque<B> ::iterator, deque<B>::iterator > result = equal_range(d1.begin(), d1.end(),
B(20));
for_each(result.first, result.second, Out<B>(cout));cout<<endl;
return 0;
}
Program outputs:

문제 3

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main() {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
vector<int> v1(t, t + 15);
set<int> s1(t, t + 15);
pair<set<int>::iterator, vector<int>::iterator > resultSet = equal(s1.begin(), s1.end(), v1.begin());
cout<<*resultSet.first<<" "<<*resultSet.second<<endl;
return 0;
}
Program outputs:

문제 4

What happens when you attempt to compile and run the following code?
#include <vector>
using namespace std;
int main ()
{
std::vector<int>v1;
v1.push_back(10);
return 0;
}

문제 5

What happens when you attempt to compile and run the following code?
# include <vector>
# include <iostream>
# include <algorithm>
using namespace std;
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator()(const T & val ) {
out<<val<<" ";
}
};
struct Sequence {
int start;
Sequence(int start):start(start){}
int operator()() { return start++; }
};
struct Odd { bool operator()(int v) { return v%2==0; }};
int main() {
vector<int> v1(10);
generate(v1.begin(), v1.end(), Sequence(1));
partition(v1.begin(),v1.end(), Odd());
for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl;
return 0;
}
Choose all possible outputs:

댓글 추가

귀하의 메일주소는 공개되지 않습니다. 필수 입력 사항은 표시되어 있습니다. *

insert code
그림의 인증번호를 입력하세요.