c++

Accessing the vector container that is inside the map container

There is a container map<string,vector<string>> Map. You need to find a specific word in the vector and output its key. Hence the question: how to access the vector that is inside the map?

Create a priority queue (each item has its own priority)

Hello! There is a task: create a queue with a priority (each element has its own priority). The items with the highest priori ... peq->next=el; peq=el; } else { peq=el; pbq=el; }; }

Generating subsets algorithm

I am studying the book "Olympiad programming"by A. Laaksonen. There is a problem about generating subsets, and the following ... , but if it is {1, 2, 3, 1}? Then it won't work anymore. Question how to finalize it, so that it finds all subsets correctly?

Using C++ iterators with arrays

Perhaps someone can explain iterators and their use with arrays, or provide relevant literature on the topic? Because I read ... f the array in this case would look like this with iterators: for(start ???; start != end; start++) cout << *start;

How do I swap the minimum and last zero elements of array A?

How do I find the last zero element and swap with the minimum one? Wrote an array and found the minimum element: #include< ... Min = A[i]; } } cout << Min << endl; system("pause > void"); return 0; }

Why does the std::unique ptr constructor swear when creating a class member variable that a type specifier is required

If you use a constructor for a smart pointer that accepts a pointer to a variable, then everything works fine in the main cod ... ~B() { std::cout << "B destroyed\n"; } }; int main() { std::unique_ptr<A> a(new A);//Works return 0; }

Sorting large amounts of c++data

So, I need to sort the csv file, it has 114318 records, I needed to use quick sort, I wrote a program, but here's the problem ... absolute_magnitude; char spectral_type[15]; double x, y, z; char constellation[5]; }; typedef struct star Star;`

Graft syntax for calling sort() c++ in a class

I tried to write a class for sorting a vector of vectors by a certain field #pragma once #include <iostream> #include ... cs_pc_Programming\C++\RD_CompAgr\RD_CompAgr\Sorter.h 25 Although the same, but not in the class compiled without errors

Android jni javah

I'm trying to create an h-file for android via javah. The com.example.test class.MainActivity. How to use javah correctly? Sh ... ses or src? Somewhere I read that the wrong javah can be used, depending on the paths in the patch(xs which is not the one).

Cross-platform way to find out the approximate amount of RAM

Actually, so far, a little clumsy method has come to mind: BYTE GetAvailableMemory(){ llu MaxMemory = Settings: ... e this clumsy memory counter and whether it will also work on Linux and mac, as on Windows (not will it put the system down)?

Generators in C++

How to write a generator in C++, as in python? For example, for the Fibonacci numbers, the generator can be written and used ... ib() print(next(g), next(g), next(g)) for f in fib(): print(f) if (f > 1000): break How do I do the same in C++?

What is a pair and where to use it?

I can't understand why such a union of two objects of different or the same type, in one object? And how is this different from map? And how or what is the point of using pair together with map?

Converting a wav file to an array

Hello everyone. You need to perform a DFT conversion of the wav file. The function is available, graphs are plotted(based on ... Qt myself, I study it in a hurry. Help us implement a function that "pulls" data from a wav file to plot a graph / spectrum.

Accessing a two-dimensional array via pointers

I need to display an array with a size of about 1000x1000 . If you constantly access the array elements via [] [], it takes a ... ointers. It should also be faster. What is the best way to run through such an array with the shortest time through pointers?

Program for processing a file of the record type, c++

Please help the novice understand what mistakes can be made. I can't figure it out for a long time. Ошибка C2360 пропуск ин ... ent.sb<<"\n"; } } break; case 5: break; } _getch(); return 0; }

What is the point of using dynamic memory allocation for variables?

Please explain to me whether there is any sense and what it is in using dynamic variables (namely variables, not arrays) (exc ... ed when necessary? P.S I understand how and why dynamic arrays are needed, I only need explanations about dynamic variables!

Converting string to integer

Please tell me the functions for translating the type string to integer in c++ Here is an example, in fact, it is necessary to drive a number from S{[2] into N]} #include <string> int main() { string S="74"; int N; return 0; }

I can't figure out what my mistake is

What is my mistake? Everything is fine here: std::string rotation(std::string common,int n) { std::string addition=common ... encode(8,"Hello World"); } I get an error: Exception in floating-point operation (memory stack flushed to disk)

C++ - how to create a two-dimensional array with an indefinite number of elements?

How to declare two-dimensional (and more-level) arrays with an undefined number of elements in it? With one-dimensional, you can do this: int arr[] = { 0 }; However, the following does not work: int arr[][] = { { 0 } }; What should I do?

"error C2078: too many initializers" when initializing a character array

Good afternoon! Please tell me why it is not possible to define an array? Declaring an array this way: char arr[]={"a", "b"}; I get this error: Error C2078: too many initializers