Questions tagged as 'vector'

1
answer

vector within vector generates duplicity of values in the second dimension

In the example below (which can also be seen in the Ideone ), I have vector of a class and within class I I have an element also vector . The point is that when doing push_back of the class, the internal vector vetint...
asked by 29.05.2018 / 04:10
2
answers

Converting a vectorstruct in C ++ in C

I'm trying to adapt a C ++ function in pure C. I changed the names of the variables and structs because it is not the case. typedef struct struct1 { int a; int b; int c; string d; } STRUCT1; typedef struct struct2 {...
asked by 18.11.2016 / 00:44
1
answer

Lawtex - how to use logic based on the field of a Vector of structs?

I have a vector that uses a struct with several variables and one of them is a Boolean. What can I do to execute something if at least one element of that vector has this variable as true? struct[STR_Dados_dos_Inadimplentes] { fields {...
asked by 07.12.2018 / 13:51
1
answer

How to put classes inside vector and manipulate variables with push_back?

It sure is something simple, but I researched and did not understand how to do. If I have, for example, the following class with two variables: class x { public: int var1, var2; }; I want to create a vector of this class, so I...
asked by 29.05.2018 / 01:54
1
answer

How to access elements of a vector of a type defined by struct?

In my code, I made the following struct declaration: struct material { int idmaterial; double rho; double precokg; }; I wanted to run this function, which reads the data from a file: std::vector<material> le_material(std...
asked by 14.05.2018 / 17:19
1
answer

Python, increasing number of numbers

My goal in the code is to print an increasing order of integers. For example: The user types 2 numbers and I want the growing order to be printed. Ex: n1 = int(input('Digite um número')) #O usuário digitou 9 n2 = int(input('Digite outro'))...
asked by 03.03.2018 / 11:03
2
answers

Is it possible to assign the first column of a line of a / a vector / matrix?

having as example a vector of two dimensions of type char 2x2: char vet[2][2]; Is it possible to assign to the first line indices of this vector? or do they work like a pointer to the other rows and columns? I tried to do it as fo...
asked by 07.09.2017 / 22:54
1
answer

Is it possible to create a std :: list with an initializer_list?

I'd like to pass a temporary std::list to a function, but I do not know if it's possible to do so. I know it is possible to pass% temporary% with std::vector : #include <iostream> #include <vector> template<typenam...
asked by 11.09.2014 / 21:18
1
answer

Get result of an expression in c ++

I'm almost finishing my expression interpreter. But I have no idea how to do the most important part: The result I would learn a lot from any idea. main.cpp #include <string> #include <iostream> #include <fstream> #incl...
asked by 20.06.2018 / 03:18
0
answers

What is the bubble short error in this code?

   I tried to solve this problem of Online Judge URI and I got to this   code, and it works for test cases smaller than the problem, and   I already looked for the error, but I can not find it.   Code:#include<stdio.h>#include<stdl...
asked by 09.04.2018 / 05:06