Pham Quỳnh Anh
New member
What will be the output of the following C++ code?
A.
1 2 3 4 5
3 4 5 0 0
B.
1 2 3 4 5
0 0 3 4 5
C.
1 2 3 4 5
1 2 3 4 5
D.
1 2 3 4 5
3 4 5 1 2
Code:
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
Valarray<int> varr = { 1, 2, 3, 4, 5 };
for (int &x: varr) cout << x << " ";
cout<<endl;
varr = varr.shift(2);
for (int &x: varr) cout << x << " ";
return 0;
}
1 2 3 4 5
3 4 5 0 0
B.
1 2 3 4 5
0 0 3 4 5
C.
1 2 3 4 5
1 2 3 4 5
D.
1 2 3 4 5
3 4 5 1 2