Shao
A large number of suitable if statements are used to find the generated random numbers
Nana
Can see your code
Nana
I don't think so
SMS
How do I implement it?
while(vect.size() < size) { num = (rand() % (max - min +1)) + min; vect.push_back(num); for(size_t i = 0; i < vect.size() - 1; i++) if(vect[i] == num) vect.pop_back(); }
SMS
if you are using c++, i will recommend <random> instead of using srand()/rand()
SMS
it has higher efficiency and lower repeatability
Nana
Ok
Nana
should I call it as a header file?
SMS
i didn't use it in the code above
Nana
Okay
Nana
Let me try it and give and you the feedback
SMS
👌
SMS
if you are using c++, i will recommend <random> instead of using srand()/rand()
https://www.learncpp.com/cpp-tutorial/introduction-to-random-number-generation/
12S21021_
hi, might you help me please? I want to make a struct factory, example: tempt.gender = gender; but when I try to compile it, there is an error about (.) Might you explain to me why (.) is wrong in my struct factory? thank you
Alfredo
Show your code
12S21021_
Show your code
struct dorm_t check_dorm(struct dorm_t *dorms, int size, enum type_t gender) { struct dorm_t temp; strcpy(temp.dorms, *dorms); temp.size = size; temp.gender = gender; return temp; }
SMS
It's given me an infinity loop
you need to remove some of your own code, they will cause an infinite loop
SMS
(this group is not event allowed to post a image...
SMS
https://pastebin.com/dCsxWmG2
SMS
(why disable image post? just because there are some spam bots?
Alfredo
(why disable image post? just because there are some spam bots?
I believe it was because a lot of users posted images of code, and in really bad quality 😂
Shao
of course
Anonymous
I want to take double input as a character
MRT
any body can help me to parse cryptocurrency value to correct price
MRT
i want to get correct value from bnc for example usdt with 18 decimal , i get value like 15000000000000000000 , correct price is 15 usd, but in qt i cant use int,long or lonlog for division to 1e18
SMS
(use strings to store the values
SMS
of course
random number table? i'm not sure what you mean
MRT
(use strings to store the values
double work fine, what is double range in cpp ?
MRT
(you should google it
i cant find :)(
SMS
i cant find :)(
just search c double range
SMS
sure thing
✞✟✞✟✞
https://sourceforge.net/projects/tinyxml/
404
/get ide
Anonymous
does anyone know how input a date like this : 4/6/2022?
Levi
/get
Abhinav
/get
SMS
does anyone know how input a date like this : 4/6/2022?
you can use scanf("%2d/%2d/%4d")
SMS
i haven't tried it yet, but i think it should work
Anonymous
SMS
if you are using cpp, you can also use printf too. it is also a part of C++. #include <cstdio>
SMS
(using cpp doesn't mean you have to use iostream
SMS
sometimes, stdio is a better choice
Anonymous
sometimes, stdio is a better choice
i write these codes for my exercises and we are limited
SMS
only iostream can be used?
Anonymous
yeah
Anonymous
i think i found the answer
SMS
i think i found the answer
can you share it with me?
Anonymous
can you share it with me?
#include <iostream> using namespace std; int main() { char slash_dummy; int d,m,y; cin >> d >> slash_dummy >> m >> slash_dummy >> y; return 0; }
ꍏꈤꀸ
I have some doubts about using local static variables in c-tor. Since static variables initialization is thread safe (starting from C++11) and c-tor is thread safe (object is created only once). But what about following case? Is this code thread-safe starting from C++ 11? class SomeClass { int id_; public: SomeClass() { static int id = 0; // safe id_ = ++id; // ??? } };
SMS
++id may cause some problems
SMS
++id may cause some problems
but i am not familiar with multithreading, for reference only
ꍏꈤꀸ
++id may cause some problems
It causes if it would be inside a regular method, which can be called from multiple threads. But I'm bothered with the fact that it's in the constructor
ꍏꈤꀸ
It causes if it would be inside a regular method, which can be called from multiple threads. But I'm bothered with the fact that it's in the constructor
Argh, if 2 threads simultaneously call the ctor then we may got the same id_, but it will be still thread safe. That's just my thoughts...
SMS
how can it be thread-safe if you get two same ids?
ꍏꈤꀸ
how can it be thread-safe if you get two same ids?
Ids are same, but its just because 2 threads got same state of static variable. It's not race condition, since constructor itself are thread safe.
SMS
i don't understand why you say the constructor itself is thread-safe
Pavel
I have some doubts about using local static variables in c-tor. Since static variables initialization is thread safe (starting from C++11) and c-tor is thread safe (object is created only once). But what about following case? Is this code thread-safe starting from C++ 11? class SomeClass { int id_; public: SomeClass() { static int id = 0; // safe id_ = ++id; // ??? } };
As far as I know, if you create multiple objects of SomeClass it's not thread safe. The variable is shared between all instances of the class and not protected from concurrent access, it doesn't matter if it's in constructor or in a member function
ꍏꈤꀸ
i don't understand why you say the constructor itself is thread-safe
https://stackoverflow.com/questions/35598311/c-constructor-thread-safety
Shao
random number table? i'm not sure what you mean
Isn't it to avoid repetition? You can define a variable to store the newly generated array and then use the for loop to judge whether the query is the same or not, if it is the same, then regenerate
Anonymous
Hi can anyone know how to remove permission screen shoot in apk?
\Device\NUL
Hi can anyone know how to remove permission screen shoot in apk?
You probably want to ask this in Reversing group
Official
😯
Anonymous
does anyone work with SDL2?
Pavel
does anyone work with SDL2?
Yes, someone works with SDL2
Pavel
you?
Can you just ask your question right away?
Pavel
No need to ask "does someone work with technology X?" before asking the question, it's a chat with 16k users after all dontasktoask.com
Anonymous
ok👍🏽