mov $22, %rax
su
how it is going?
mov $22, %rax
I'm trying to use gdb to see if I can check the execution time between two breakpoints, but I think I can't do that. I tried to use reppl.it but it does not compile in debug mode and anyway, even if I do that manually, I still have to use gdb as the debugger... so same problem
mov $22, %rax
I don't know why but if n > 520184 it breaks
mov $22, %rax
Maybe I know why...
mov $22, %rax
why?
The debugger tells me that the problem is in line 31, where I write primes[counter] = i; I use counter to initialize dynamically the array of primes using a maths theorem which says that primes between 1 and n are not more than n/log(n), but since the problem is signaled here, maybe the program tries to access a non-initialised space, mabye because the program finds somehow counter + 1 primes (don't know how), so that everything brakes
mov $22, %rax
If that is true... and I really don't know... I should be able to fix it really easely
mov $22, %rax
you mean, not dynamically?
su
you mean, not dynamically?
using calloc, not malloc
mov $22, %rax
ok
mov $22, %rax
It finds 78498 when I just allocate 72383 doublewords. Either my algorithm doesn't work or I haven't understood the formula n/log(n) to understand how many primes are there between 1 and n
mov $22, %rax
Now I'm tired, so I'll see tomorrow how to solve this.
mov $22, %rax
using calloc, not malloc
I changed, but the only difference I can see in in the syntax
su
what difficulties to calculate 1000000 prime numbers?
su
allocate 1000000 array elements
mov $22, %rax
Yeah bro, but I don't wanna allocate so much to store the first 3 primes... I wanted to do something dynamically. I understood that I used the wrong formula tu approximate whe number of primes between 1 and n, that's it
mov $22, %rax
allocate 1000000 array elements
now it works, I changed formula
mov $22, %rax
it works also for numbers up to 10^9, but it takes a lot of time
mov $22, %rax
30 seconds just to elaborate
mov $22, %rax
that is slow, that is slow as hell
su
that is slow, that is slow as hell
ok, good. cache primes, do not use i, i+1, i+2, use 6*i-1,6*i+1, cause 6i+2 == 0 mod 3, 6i + 3 == 0 mod 2, 6i + 4 == 0 mod 2, and 6i + 5 == 6i -1 mod n
Mino
Someone Know How can create an float vector with push_back?
klimi
Someone Know How can create an float vector with push_back?
How to create float vector and then use push back or what are you asking?
Mino
I'm trying to pushback floats values in a vector (like [0.01,0.02..]), but when I print the components of the vector are wrong
Mino
I used a for loop
Mino
Mino
I want create an vector [0.01,0.02....10]
Mino
How can I do?
ברני
Why you're working on a site and not on Microsoft Visual Stodio?
ברני
And please delete before you'll get warn
olli
I want create an vector [0.01,0.02....10]
e.g. double StepSize = 0.01; double Min = 0 + StepSize; double Max = 10; std::vector<double> V; for (double Current = Min; Current <= Max; Current += StepSize) { V.push_back(Current); }
just me
Hello friends, how are you? I have an application code that I want to adjust to make the latest version of the application work. There is a jailbreak. Does anyone know what ..?
Roshan
One thing I can say is that you're assigning 0.01, 0.02 etc in index 0.01 etc. which is a float(☉ 。☉)!
Kingsun
Xqq
M.Khorram
#ot
Anonymous
/warn screen photo
Anunay
i += 1 in the the loop statement t[i] = t[i-1] + dt in the loop score
Anunay
Add a condition for i = 0
Anonymous
Arjun
Hii
Arjun
Hi
Arjun
Hii
ברני
Hey again... I did a stupid thing and I don't know how to make it short.... void countArray(int arr[][COLS], int cols, int rows) { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { arr[0][2] = arr[0][0] + arr[0][1]; arr[1][2] = arr[1][0] + arr[1][1]; arr[2][2] = arr[2][0] + arr[2][1]; arr[3][2] = arr[3][0] + arr[3][1]; printf("%d ", arr[i][j]); } printf("\n"); } } how do I make it without printing every single cell? or what shell I ask Google exactly? lol..
ברני
Didn't understand
Manav
Didn't understand
What statement is printing things to the console according to you?
𝙑𝙞𝙨𝙝𝙖𝙡
Didn't understand
Just remove the print statement if you don't want to print. It's obvious
𝙑𝙞𝙨𝙝𝙖𝙡
printf?
Yes. Looks like this is your first time looking at a piece of code.
ברני
Yes. Looks like this is your first time looking at a piece of code.
If you don't understand my question don't answer
Manav
printf?
Yes, remove or move it, if you don't want it to print it. Also other four statements inside for loop doesn't make sense
ברני
Yes, remove or move it, if you don't want it to print it. Also other four statements inside for loop doesn't make sense
I'm asking how to print the long code I did short in what statement because I'm doing it wrong, I want a short way to write the cell plus cell = 3thcell
ברני
What do you mean by long code?
I did every cell plus the other cell = the last I didn't get how to do it not in that way, because if I'll have millions of cells that won't be the way..
𝙑𝙞𝙨𝙝𝙖𝙡
In place of numbers
ברני
Use i and j
On the first?
𝙑𝙞𝙨𝙝𝙖𝙡
On the first?
You have have to understand what will be the value of i and j as the loop increments and use their values in place of the numbers according to what you want.
Manav
On the first?
You might want to think in terms of coordinates.
ברני
You have have to understand what will be the value of i and j as the loop increments and use their values in place of the numbers according to what you want.
I'm trying to understand logecly how to make it with out writing every single cells.. (I'm 2d array begginer, just started with the 2d yesterday)
Manav
𝙑𝙞𝙨𝙝𝙖𝙡
𝙑𝙞𝙨𝙝𝙖𝙡
So make logic in your head with where you should use i and where j
Manav
Here, might want to read on mathematical induction to recognize patterns, if it is very difficult to find a pattern to loop with. https://youtu.be/GvbrtnEYRpY
Makgato
Hello guys please help me can i use code block for programming sockets in C++ ? . I tried to search it via YouTube i didn't find answer
Makgato
You can use any ide.
Thank u so much i will try 😀😀
Anonymous
Would this be a... good way to implement a basic plugin audio IO? Plugin: https://gist.github.com/46e96a9b56cc1f876f6355e7cba1a992 Engine: https://gist.github.com/56c476a9b0b0ae34934bfb1277e1cded
Anonymous
Guyes pls help me i found good algorytm for printing lines "Bresenham's line algorithm" but i am lost how implement it in 2D array can please someone help me? Thanks
%#%*%*
Can anyone please tell me.. How to store a character in a variable whose ascii code I already have in another variable..
%#%*%*
you already store it. if you want to printf it use %c or cast to char for cout
Can you please elaborate the phrase " cast to char for cout " ..i am not much learned in C so i'm not familiar with this phrase..
Alex
what are you trying to achieve? you already store this character. there is no difference between char c = 'A' vs char c = 65(ascii one byte encoding)