TP2, Exercice 1.
This commit is contained in:
parent
b8fe134405
commit
709e3d3b46
1 changed files with 25 additions and 1 deletions
|
@ -1,7 +1,31 @@
|
||||||
|
#include <cstddef>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void question1(uint maxVec);
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
std::cout << "Hello TP2 !" << std::endl;
|
question1(10);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void question1(uint maxVec)
|
||||||
|
{
|
||||||
|
std::vector<float> v1;
|
||||||
|
const float value = 1.0f/maxVec;
|
||||||
|
for(uint i=0; i<maxVec; i++)
|
||||||
|
v1.push_back(value*i);
|
||||||
|
auto v2 = v1;
|
||||||
|
for(size_t i=0; i<(maxVec/2); i++)
|
||||||
|
v2.pop_back();
|
||||||
|
|
||||||
|
// printing
|
||||||
|
for(const auto& val : v1)
|
||||||
|
std::cout << val << "\t";
|
||||||
|
std::cout << std::endl;
|
||||||
|
for(const auto& val : v2)
|
||||||
|
std::cout << val << "\t";
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue