Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice bad practice; avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice; avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice; avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice ,; avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice , avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice ; avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice, avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice, avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code.
Include the right things
You're starting with:
#include <bits/stdc++.h>
using namespace std;
The second line is bad practice, avoid it. Typing std::
is not a burden. The former is definitely unacceptable - that's a compiler-specific file that you don't want to be including. Just include the actual headers you need:
#include <iostream>
#include <algorithm>
#include <vector>
Use algorithms and iterators
Rather than writing your own loop to perform a sum, you could use the standard algorithm for this: std::accumulate
:
int sum = std::accumulate(v.begin(), v.end(), 0);
Also they wanted you to use iterators to find the median, which would be:
auto median_it = std::next(
v.begin(),
std::distance(v.begin(), v.end()) / 2);
Where's the rest?
There's a lot of text in that question that I don't think you addressed in your code. Looks like we need a std::map
or something.