To prevent flaming for cheating or anything elseHere is proof that the examination is accessible for anyone and that it's a old one
http://www.ida.liu.se/~TDIU04/exam/old_exams/080314/?C=N;O=DTo prevent flaming for cheating or anything elseThis is a solution example source for a examination @ Linköping University.
The problem is that it wont compile.
Error message below source.
Before contacting the teacher to ask for a correction I wanna try here.
I am not a student at LIU. I wanna use this examination to measure my
own knowledge and when there is no correct "answer" to look at when
I am correcting myself to see what I need to read more about etc.
CODE
/*
* uppgift1.cc TDIU04 2008-08-22, uppgift 1.
*/
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
using namespace std;
int main()
{
istream_iterator<int> input(cin);
istream_iterator<int> end;
vector<int> v(input, end);
copy(v.begin(), v.end(), output);
cout << "\n\n";
ostream_iterator<int> output(cout, " ");
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
copy(v.begin(), v.end(), output);
cout << "\n\n";
int five_percent = static_cast<int>(0.05 * v.size());
cout << "5% = " << five_percent << " tal\n\n";
v.erase(v.end() - five_percent, v.end());
v.erase(v.begin(), v.begin() + five_percent);
copy(v.begin(), v.end(), output);
cout << "\n\n";
int sum = accumulate(v.begin(), v.end(), 0.0);
cout << "summa = " << sum << "\n\n";
cout << "medelvärde = " << static_cast<double>(sum) / v.size() << "\n\n";
return 0;
}
In function `int main()':|
18|error: `output' undeclared (first use this function)|
18|error: (Each undeclared identifier is reported only once for each function it appears in.)|
40|warning: converting to `int' from `double'|
I use code::block with GNU GCC Compiler
Anyone know how to declare output to make it compile?
This post has been edited by FrozenSnake: 4 Sep, 2008 - 07:04 PM