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

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

문제 1

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
void myfunction(pair<int, int> i) {
cout << " " << i.first;
}
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
map<int, int> m;
for(int i=0; i < 10; i++) {
m[i]=t[i];
}
for_each(m.begin(), m.end(), myfunction);
return 0;
}
Program outputs:

문제 2

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: 1 2 3<enter>?
# include <iostream>
# include <string>
# include <sstream>
using namespace std;
int main ()
{
string s;
getline(cin, s);
stringstream input(s);
stringstream output;
for( ; !input.fail() ; )
{
int i;
input>>i;
output<<hex<<i<<" ";
}
cout<<output.str();
return 0;
}
Program will output:

문제 3

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 10*(1+(start++ %3)); }
};
int main() {
vector<int> v1(10);
generate(v1.begin(), v1.end(), Sequence(1));
unique(v1.begin(),v1.end());
for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl;
return 0;
}
Program outputs:

문제 4

What happens when you attempt to compile and run the following code?
# include <string>
# include <list>
# include <iostream>
using namespace std;
template<class T> void print(T start, T end) {
while (start != end) {
std::cout << *start << " "; start++;
}
}
int main() {
string t1[] ={ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
list<string> l1(t1, t1 + 10);
list<string> l2(l1);
l2.reverse(); l1.splice(l1.end(),l2);
l1.unique();
print(l1.begin(), l1.end()); cout<<endl;
return 0;
}

문제 5

What happens when you attempt to compile and run the following code?
# include <deque>
# include <iostream>
# include <algorithm>
#include <functional>
using namespace std;
class B { int val;
public:
B(int v=0):val(v){}
int getV() const {return val;}
B operator +(const B &b )const { return B(val + b.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<<" "; } };
template<typename A>
struct Add : public binary_function<A, A, A> {
A operator() (const A & a, const A & b) const { return a+b; } };
int main() {
int t[]={1,2,3,4,5,6,7,8,9,10};
deque<B> d1(t, t+10);
deque<B> d2(10);
transform(d1.begin(), d1.end(), d2.begin(), bind2nd(Add<B>(), 1));
for_each(d2.rbegin(), d2.rend(), Out<B>(cout));cout<<endl;
return 0;
}
Program outputs:

댓글 추가

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

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