Skip to content

Conversation

@kodex154
Copy link

No description provided.

Comment on lines 62 to 66
arr_R[i]=distrib(gen);
}

for (int j=0;j<3;j++){
arr_B[j]=distrib(gen);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potresti inizializzare entrambi gli array nello stesso loop

Comment on lines 39 to 44
for(int i =0;i<x;i++){
if(arr[i]<arr[i+1]){
int temp=arr[i];
arr[i]=arr[i+1];
arr[i+1]=temp;
check=true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per come è scritto l'algoritmo stai andando a leggere fuori dai bound dell'array!

#include <random>
using namespace std;

void sort(int *arr,int x){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Piuttosto che chiamarla x, usa un nome più chiaro come size, length o persino n.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grazie del consiglio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants