vector

How to implement rotation of a two-dimensional vector by 45 degrees?

How to implement rotation of a two-dimensional vector by 45 degrees, found solutions for 90, 180, 270. Such a repeat can be i ... tches with the condition(which is logical), but how to implement that the values that fit were used for further calculations?

C++: std::vector. push back () and classes

In my program, I created the Score class. In it, I created an empty constructor, as well as a constructor in which the passed ... ^ I sincerely do not understand what I am doing wrong and ask for help to understand. In advance thank you.

Bitwise shift of a Double C++number

Greetings! I'm a novice programmer, so if the question is "childish" - do not cut the bull. There is a lab in which you need ... le.size(); i++) { std::cout << arrDouble[i] << " "; } std::cout << "\n\n"; system("pause"); return 0;

As from std::vector delete a range of elements?

I need to write a program that removes a range of values from a vector. My code: std::vector<int> vector = { 0, 1, 2, ... need to write my own New: for (int index = begin; index <= end; ++index) { vector.erase(vector.begin() + index); }

C++ Vector and its Push back method

There is a certain code: A a1; A a2; A a3; std::vector<A> a; std::cout << "Push back a1" << std::endl; a.p ... ion/destruction of such a number of objects will really hurt me. What should I do? Or should I look for some other container?

The for each function in the vector library

You need to complete the task: Change the sign of all array elements between the first maximum and the last maximum eleme ... it means?: std::for_each(nums.begin(), nums.end(), [](int &n){ n++; }); , i.e. everything after the square brackets?

c++ Vector itself overwrites the values in it

I'm just starting to try vectors and I don't understand why the values change in it. I use Qt 5.8.0. During for, the vector ... es of yrus[0] change along with STRs How do I fix it so that "1" remains in the vector during the execution of the for loop?

Get the column vector of a c++matrix

Let be the matrix vector< vector<int> > a = { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 42} }; I ca ... y to get the same simple vector-column matrix? That is, for example, by the index 2 to get a vector that contains {3, 7, 11}.

c++: allocating space for a container

Please tell me, if I have a container and I know how many elements there will be in it, to speed up the work, I can select th ... lear(); Do I need to reserve the volume again, or is it possible to make such a clear() so that the reserved memory remains

Error: "Breakpoint triggered"

There is a program: reads data from a file to a string, parses it by ";", writes it to a string vector, then converts the dat ... << pgn[i - 1].x << " - " << pgn[i].y << endl; } } else{ cout << "Open error!"; } }

Python, increasing order of numbers

My goal in the code is to print an increasing order of integers. For example: The user enters 2 numbers and I want the ascend ... é [2,9] nessa ordem(o menor primeiro e depois o maior) What would be the best way to do this? Note: I'm a python beginner

How to use the C++vector class?

Necessarily need the library #include<vector.h> To create it vector <int> c; Question: How to store values in it and read them?

Object vector ordering

I'm making an application that sorts a vector of objects. These objects are Cartesian points, defined in the following class: ... sort.cpp:33:5: error: no matching function for call to 'sort' std::sort(myvector[0], myvector.end()); What's wrong?

How does it work to use a struct vector? (C++)

I would like help to understand how it works to declare a vector of type struct. In the example of the code below I create th ... nfigcarros> cars(C); } Could anyone help me understand this ? I'm not finding much searching about struct vectors.

Limit, or capacity of a vector

Imagine asking " when the capacity reaches the limit should warn the user" I have a vector of integers with 15 positions, and ... etor[MAX]){ int i; for(i=0; i<MAX; i++){ printf("O valor da posicao %d e: %d\n", i+1, vetor[i]); } }

Fails when accessing a vector option that does not exist

I did a few years ago an inheritance algorithm and polymorphism it is working properly but if I type 7 which is a non-existen ... al, o ecossistema tem " << ecossistema.size() << " mamífero.\n\n"; return 0; } int main() { getDetails(); }

Printing a vector Diferenças differences between C++ and C ++ where did I go wrong?

I'm having trouble printing structs vector in C, in C++ it worked... First I will show the version in C with problems (in ex ... do; clock_t time; }CACHE; Anyway, I'd like to know what am I wrong with C code to not get the same result as C ++ code

How to return 2 vectors of different types in C++

I perform a calculation and my result is saved in a vector<int> And a vector<string> How do I make ... ector of integers in a vector of string, but I also do not know if it is possible to pass more than one vector of a function.

Class c++ has no member named

I am starting the development of a list list to represent an in-memory graph. I did only this first part and I am getting th ... =0; i < listNos->size(); i++){ if(listNos[i].getId() == id) return true; } return false; }

Check if a certain value is in the vector

I created the vector fragil that will accept several user inputs, these inputs that will (or not) be the position of other el ... ntador(j)+1; end if contador (j)>1 porCobrir(j)=0; end end n_porCobrir=sum(porCobrir); end end