c++

Find the maximum element in the array

What is the error? #include <stdio.h> #include <conio.h> #include<stdlib.h> main() { int m=5,n=5,i,j,max; i ... [1][1]=max; for(i=1;i<5;i++) for(j=1;j<5;j++) if(a[i][j]>max){ max=a[i][j]; } printf("max a[i][j]",max); getch(); }

C++Quick sort implementation

I'm trying to implement a quick sort algorithm, but something goes wrong. It seems that I write directly from the book (Korme ... ion returns a pointer to the reference element. Then the recursive QuickSort function is called, which should sort the array.

Explicit instantiation of a template constructor and a member function

To use a template class defined in the .cpp file, you can explicitly instantiate this class: template<typename T> stru ... iating it, everything works without errors, but without explicitly instantiating the function, its use gives a linking error.

Visual Studio 2012 Encoding

I'm building a project that contains an error. Instead of the error description, it appears: 1>MSVCRTD.lib(crtexe.obj) : e ... ЁрчЁх°хээ√ї тэх°эшї ¤ыхьхэЄют: 1 What can it be, how can I configure it (so that the encoding is normal English or Russian)?

The Josephus problem using a cyclic list

Linked lists in C++ - there is an example here, but it is a little unclear. struct node { int item; node *next; node(int x, node *t) { item = x; next = t; } };

Warning C26451 | Arithmetic overflow

DWORD DecimalBaseAddr = GetModuleBase (gameName, pID); cout << "The Base Address is: " << DecimalBaseAddr << ... I looked at GetLastError () - outputs error 12b, that is, ReadProcessMemory() is not fully executed, what could be the error?

What is the meaning of this construction?(int i{};)

int i{}; What does this construction do? As far as I understand, this is a variable, but why do we need parentheses?

Sorting a two-dimensional dynamic array by c++strings

Created a dynamic array in c++, filled it in. Now you need to sort by the first element of the rows. That is, so that the row ... cout << endl; } for (int i = 0; i < rows; i++) { delete[] arr[i]; } delete[] arr; }

C++List Template

There is a doubly linked list, you need to make a template for it so that you can interact with different types of data, tell ... v->next = NULL; pv->prev = NULL; return pv; }; Underscores Node* with error: missing argument list for "Node".

How to pass a C++class (structure) template to a function template

There is a structure template template<typename T> struct spec { T* values; int size = 0; }; You need to make ... ze] = val; st->size = st->size + 1; } But the error is отсутствует список аргументов для параметр шаблона template

Error when compiling any project in Code:: Blocks

I installed a new version of Code:: Blocks 12.11; I wanted to run the old project - and then I get an error! At first I didn' ... inutes, 0 seconds) ===| Who can tell you what the problem is??? I can't start anything!!! We have to sit on VS2012 for now.

Error LNK2005: already defined in.obj

Please tell me how to overcome the problem? error LNK2005: already defined in .obj I can't say that I haven't tried both # ... compiled into object files normally, but the linking does not take place. Help please. I don't know what to think of even ...

Calculate the sum of the matrix elements

You need to calculate the sum of the elements of each row of the matrix v (4,5) or the number of positive elements of the col ... lt; endl; } cout << endl; for (int i = 0; i < N; i++) delete [] A[i]; delete [] A; }

The letter I when read in C

The problem is, I read a line from the file with this code setlocale(LC_CTYPE,""); char path[]="1.txt"; FILE* fp = fopen(path ... = '\0'; } else { printf("Входной файл отсутствует\n"); exit(1); } But it reads to the first letter " I " what's the matter?

How to skip/jump to the end of a line when reading a C++file

There is a file with the text. The program reads everything by character. If it finds, for example, a letter from the English ... ищет англ символы. if (eror) { // если функция нашла то... ПЕРЕЙТИ НА СЛЕДУЮЩУЮ СТРОКУ } } }

Implicit call to the copy constructor

#include <iostream> struct A { A() { std::cout << 'A'; } A(const A&) { std::cout << 'a'; } }; ... the program output ABAb And not what I expected ABab Why did the developers of the standard decide to set this behavior?

Why do I need constant function parameters?

Why do we need constant function parameters? We need a real use case. That is, when it is worth writing, for example, so voi ... bout why you can not overload, I have a question "why are you needed". I didn't see the answer to my question in the answers.

C++ stl map

Works:(All in one file ConsoleApplication4.cpp) #include <string> #include <map> using namespace std ... 1169: one or more multiply defined symbols found ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

STL C++ stl random

We need a lambda function that generates a random number of stl by the generator, normal scattering . minimum -50 max 50. the ... = []() { return std::mt19937 gen{std::random_device()()}, std::uniform_int_distribution<int> uid(-50, 50); };

How to set the number of decimal places for a specific c++variable

There are three variables of type double. You need to make 1 decimal place for the first variable t, and make 3 decimal places for the remaining two x and y. How can this be implemented?