C ++ – what am I doing wrong? Incorrect values ​​stored in an array

Please help me, I'm learning C ++ and encountered a certain error in arrays.
The program asks the user for the number of rows, then the number of columns that the matrix will have, and prompts the user to insert the values ​​to fill the matrix. The error occurs when trying to print the elements of the matrix, if the matrix has 3 columns and 3 rows, it displays incorrect numbers that have never been saved, help from fa: & # 39; (

#include
#include
#include
using namespace std;
int main(){
    int cafi,caco,vael;
    cout<<"Cantidad de filas que desea"<>cafi;
    cout<<"Cantidad de columnas que desea"<>caco;
    for(int i=0;i>array(i)(o);
            if(i+1==cafi&&o+1==caco){
                for(int ia=0;ia<=i;ia++){
                    for(int io=0;io<=o;io++){
                        cout<<"El valor del elemento situado en la fila "<

postgresql – Postgres – creates an array of all row IDs

That's my question:

SELECT p.*,
       array_agg(p.id) OVER() AS places_ids,
    (CASE
    WHEN EXISTS(
        SELECT id
        FROM user_favorites uf
        WHERE uf.place_id = p.id
               AND uf.user_id = 1
               AND uf.deleted_at IS NULL
        )
        THEN true
    ELSE false
    END ) AS favorite
FROM (SELECT
    DISTINCT ON (urv.object_id)
    urv.id as recent_id,
    p.* AS place
    FROM user_recent_visits urv
    JOIN places p on urv.object_id = p.id
    WHERE urv.user_id = 1 AND urv.object_type = 'PLACE' AND p.deleted_at IS NULL ) AS p
ORDER BY p.recent_id LIMIT 5

I have a problem with ABOUT() Function. At this point I want to get an array of all lines p.id.
However, this function returns an array of IDs selected in the subquery (total number of records 36). I was expecting to get only 5 IDs out of 5 records ORDERED from 5 and limited to 5.

Why it doesn't work as expected and how to fix it.

Thanks a lot.

8 – Should a block render array created with EntityViewBuilderInterface :: view render the complete block template or only inner fields?

After rendering custom blocks in templates, the following error appeared: Quick Edit was unable to match the rendered entity field markup. What I've done so far:

In order to render custom blocks repeatedly in templates, I wrote this function in mytheme.theme ::

function render_block_in_template($block_id) {
  // $block = Drupal::entityTypeManager()->getStorage('block_content')->load($block_id);
  $block = Drupalblock_contentEntityBlockContent::load($block_id);

  if(!empty($block)) {
    $block_content = Drupal::entityTypeManager()
      ->getViewBuilder('block_content')
      ->view($block);

    if($block_content) {
      // kint($block_content);
      return $block_content;
    }
  }
}

And I call it mytheme_preprocess_node ::

function mytheme_preprocess_node(&$variables) {
  $node = $variables('node');

  if($node->bundle() == 'some_bundle') {
    $variables('some_block') = render_block_in_template(12);
    $variables('some_other_block') = render_block_in_template(13);
    // ...
  }
}

Then I render the blocks in node--some-bundle.html.twig ::

{{ some_block }}
{{ some_other_block }}

So far, so good. But I got this js error from quickedit.js:

Error: Quick Edit could not match the markup of the rendered entity field
(With (data-quickedit-field-id="block_content/12/body/fr/full")) With
the corresponding rendered entity markup: no parent DOM node found
With (data-quickedit-entity-id="block_content/12"). It is typical
caused by submitting the theme for this entity type
Print the attributes.

This brought me to this problem: custom blocks abort the layout builder module – Quick Edit was unable to match the markup for rendered entity fields, but applying the patch didn't change anything, and upon further reading, I found that this wasn't accurate related.

If I {{ kint(some_block) }} In branch, the key is #attributes with the expected values ​​here:

Enter the image description here

and this is the HTML output:

// FIELD CONTENT

Finally, the error is corrected by manual wrapping with the following error:

So it seems that the above Wrapper part the block template is not rendered, only the fields are there and it causes the error.

Is there really a mistake or am I doing something wrong?

Algorithms – Why does MergeSort have O (n) space complexity when it divides the array protocol (s) times?

I know that this is a common algorithm with a lot of analysis, but when I was looking for an answer, all I found was "Merge Sorting has O (n) Auxiliary Space because it copies the array into L and R".

I don't understand this because it is called recursively before operations are performed, the entire array is still divided log (n) times. If we follow the binary tree diagram that represents the recursion, we see (if n = 16) that it divides into 2×8, 4×4, 8×2, 16×1.

Since all of these divisions occur before merging, why is the auxiliary space O (n) and not O (nlog (n))?

postgresql – How can I select the rows affected overall and get the row result as an aggregated array?

I know I can use count(x) OVER ()but then I get the total as a column in each row, in which I would probably like to return an aggregated row with the total and the affected rows:

({
  total: 100,
  rows: (...)
})

NOT:

({ total: 100, ... }, { total: 100, ... }, { total: 100, ... }, { total: 100, ... })

I tried to play with it json_agg, array_agg, Grouping, etc.

Forms – The button title in a render array cannot be assigned html_entity_decode

Here is the code that is in my extended class RegisterForm::

$title=$this->t("M'inscrire") // notice the apostrophe in French
// the $element variable is the action sub array of the form
$element('submit')('#value') = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
dpm(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));

Unfortunately, my submit button appears as follows M'inscrire
And strangely, the dpm function prints it the way it should be

Use Javascript to get a single value (no loop) in the array of objects

I want to use javascript to get the value of "BG_S_event_id" in the array of objects below:

myArray = [{"BG_S_event_id": "200311001", "BG_S_sec_name": "CLUB GAMES", "BG_S_sec_num": "1", "BG_S_ctd_id": "12578256", "BG_S_atd_id": "CLG_T" "S BG_S_tot_rnds ":" 1 "," BG_S_lst_pair ":", "BG_S_dtlrec01": "1", "BG_S_operator": "XX", "BG_S_status": "", "BG_S_k_factor": "BG_S_r_system": "R"}]

Improve performance: Create a dictionary and frequency array from a long string in Python

I have an X_train record, which is an array, with each entry being an email (a string). There are 11,314 emails, each about 500 characters long. (X_train is a processed version of the training data in the newsgroups record.)

Ultimately, my goal is to build a tf-idf function from scratch (knowledge of which is probably not required to answer my question). To get there, I created a lexicon that contains each unique word in X_train once and only once. My lexicon contains 211441 elements. I also need an array in which each entry frequenz_train (i) is the number of emails in which a certain term lexicon_train (i) appears.

I construct the frequency array as follows:

frequency_train = np.zeros(211441)
for i in range(211441):
    count = 0
    for email in X_train:
        if lexicon_train(i) in email:
           count = count + 1
    frequency_train(i) = count

In the same cell, I also do something similar with the test data X_test. I did this in Jupyter Notebook and this process is taking time longer time. An earlier and very similar task took about 90 minutes. I suspect that I am doing this task as slowly as possible. Is there a faster way to do this?

Edit: I would also appreciate answers explaining why this process should take a long time.

Remove Javascript object from an array

I have to remove an object from an array with javascript without JQuery.

My object is.

var prePlantio = (
    {
        "Dessecação": (
            { id:1,produto: 'Fortenza', dose: '60', area: '10' },
            { id:2,produto: 'Maxim', dose: '70', area: '10' },
        )
    },
    {
        "TS": (
            { id:4,produto:'Fortenza', dose: '90', area: '10' },
            { id:5,produto:'Maxim', dose: '100', area: '10' },
        )
    }
)

I want to remove "Dehydration"> id = 2

My removal code was preserved.

var removeItem = function(where = 'prePlantio',product = 2){
    let etapa = eval(where);    

    var index = Object.values(etapa(0)).map(function(item) { 
        return item.id;
    }).indexOf(product);
    Object.values(etapa(0)).splice(index, 1);
}

JSFiddle