Jest to kolejne zadanie z Thinking in C++. Trzeba utworzyć wektor vector<float>, umieścić w nim 25 liczb float z pomocą for i wyświetlić. Poniżej to, co napisałem. Próbowałem rozwiązać sprawę użyciem iteratorów i wskaźników, ale coś robię źle.
#include <iostream>
#include <vector>
#include <conio.h>
using namespace std;
int main()
{
vector <float> v;
float n;
n=(1/2);
short j=0;
vector<float>::iterator i;
for(int i=0; i>=25; i++)
{
v[i]=n;
n+=(1/10);
}
for(i=v.begin()-1; i!=v.end()-1; i++)
{
cout << "[" << j << "]: " << *i << endl;
j++;
}
getch();
return 0;
}
Program się kompiluje, ale po uruchomieniu nic się nie wyświetla.
Szukałem na google pomocy, ale nadal nie mogę sobie poradzić.