Anshul
Okay but what other underlying container I can give?
Anonymous
Okay but what other underlying container I can give?
For priority queue it can either be a vector or a deque. For stack it can be vector, deque or list. For queue it can be list or deque
Anonymous
Anshul
Okay
Anshul
Thanks
ببب ب
Does anyone here perform code criticism that is factual?
Anonymous
Please I have a question
Anonymous
If I learn programming is there need to learn web design?
Pavel
If I learn programming is there need to learn web design?
No need to, especially if we're speaking about C/C++
Anonymous
Q4. Write a program that reads from the user a matrix Nx3. The matrix contains employees' information. The first column holds employees' names. The second column contains vaccine status, which is either 0 or 1. Ones for employees who got the vaccine and zeros for not taking it. The 3rd column for COVID infected employees, which is either "yes" or "No". Yes, is for currently infected employees and No is for not infected. 1. Find the percentage of employees who got the vaccine. 2. Find the percentage of employees currently infected with COVID.
olli
Writing Cplus
that's not a question. There is no point in doing your homework for you
Anonymous
string query2= "update test set name = concat (substr(name, 1,3), repeat ('',char_length(name)-3))";
If you update the table,you can't unmask it. Btw your questions are no longer C++ questions.
Sandeep
If you update the table,you can't unmask it. Btw your questions are no longer C++ questions.
May be I shoul write an encode func in c++ func and call it in SQL stmt
Anonymous
May be I shoul write an encode func in c++ func and call it in SQL stmt
You can just retrieve the data from the database as is using a simple select statement and mask PII before displaying it.
Anonymous
This is nice but in the question he said update the tables
If you update the tables with a masked value (like how you are doing), you can't unmask it. Is unmasking required? If yes, then your only option then is to encrypt the PII in each record with an encryption key and store the encryption key in some other table (not a secure way of doing things)
shriman_deepak
Is there anyone who knows about FUNCTIONAL PROGRAMMING , CLEAN.
Pavel
First, this is a group about C/C++, Java is off topic here Second, read this: https://bit.ly/3jNHlra
Anonymous
Can anyone help get an open source ac97 driver added to ReactOS? The working version of it that another developer worked on can be found at https://github.com/TheDeadFish/reactos/tree/ac97_import_new2
Anonymous
Could anyone please recommend a best books to refer for algorithms and data structures in C? (Beginners)
Anonymous
Here is proof of it working in ReactOS: https://www.youtube.com/watch?v=Hr_Geq8GkdE
Ni
Guys, quick question: How to create a class with an array member, whose size is given by the class constructor, such as the following (ugly) code: class A { public: A(int size) { nums = std::malloc(size); } private: int nums[]; };
Anonymous
Guys, quick question: How to create a class with an array member, whose size is given by the class constructor, such as the following (ugly) code: class A { public: A(int size) { nums = std::malloc(size); } private: int nums[]; };
Don't. Use a vector instead. class A{ private: using sz = std::vector<int>::size_type; public: A(sz size): length(size), vec(size){} private: sz length; std::vector<int> vec; };
Anonymous
Is there anyone who knows about FUNCTIONAL PROGRAMMING , CLEAN.
Ask your question directly as long as it is related to functional programming support in C++ (which is very limited btw). If you intend to use Haskell, Erlang or other languages or if your doubt is on Lambda Calculus, go to a group appropriate for that.
Anonymous
Since sizeof is a compile time operator, can we say that the result produced by it is hardcoded into the executable binary?
Anonymous
Yes.
Cool. Thanks.
Anonymous
A government research lab has concluded that an artificial sweetener com- monly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is possible to drink with- out dying as a result. Write a program to supply the answer. The input to the program is the amount of artificial sweetener needed to kill a mouse (use 5 grams), the mass of the mouse (use 35 grams), and the weight of the dieter (use 45400 grams for a 100 pound person). Assume that the lethal dose for a mouse is proportional to the lethal dose for the human. A single can of soda pop has a mass of 350 grams. To ensure the safety of your friend, be sure the program requests the weight at which the dieter will stop dieting, rather than the dieter’s current weight. Assume that diet
Anonymous
soda contains 1/10th of 1% artificial sweetener. Use a variable declaration with the modifier const to give a name to this fraction. You may want to express the percent as the double value 0.001. Your program should allow the calculation to be repeated as often as the user wishes.
Dima
wtf
Anonymous
is there a group for talk about csapp
shriman_deepak
Ask your question directly as long as it is related to functional programming support in C++ (which is very limited btw). If you intend to use Haskell, Erlang or other languages or if your doubt is on Lambda Calculus, go to a group appropriate for that.
Thanks, i am 1st year Bsc student and there's a course of functional Programming in my syllabus (CLEAN) Do you have any idea or suggestions about it, if u don't mind u can answer this personal question.
Anonymous
#include <iostream> using namespace std; int main() { int T,N,S,f; cin>>T; for(int i=0;i<T;i++) { cin>>N>> S; f=abs(S-N); if(N==S){ cout<<N<<endl; } else if(S==1){ cout<<"1"<<endl; } else if(S==0){ cout<<"0"<<endl; } else{ cout<<f<<endl; } } // your code goes here return 0; }
Pavel
Can you detect problem?
What kind of problem? Compilation error, runtime error, or logical error? Or codestyle issue, for example?
Sandeep
Yes.
int main(void) { cout << endl; cout << "Masked values are" << "\n"; DisplayMasked(); cout << "\n"; cout << "\n"; cout << "UnMasked values are" << "\n"; cout << "\n"; DisplayUnmasked(); cout << "\n"; cout << "\n"; compute_alphabeticallyfirst(); return EXIT_SUCCESS; try { sql::Driver* driver; sql::Connection* con; sql::Statement* stmt; sql::ResultSet* res; sql::PreparedStatement* prep_stmt; driver = get_driver_instance(); con = driver->connect("tcp://localhost", "root", "27640822aC@"); con->setSchema("wrestling"); stmt = con->createStatement(); res = stmt->executeQuery("SELECT * from personal_info1"); while (res->next()) { sql::ResultSet* res1; string name = res->getString(2); reverse(name.begin(), name.end()); name = "*" + name + "*"; string val = res->getString(2); stmt->executeUpdate("UPDATE personal_info1 SET Name = '"+ name+"' WHERE Name = '"+ val+"'"); stmt->execute("COMMIT"); } delete res; delete stmt; delete con; } catch (sql::SQLException& e) { cout << "# ER: SQL-Exeption in " << FILE; } cout << endl; return EXIT_SUCCESS; }
Anonymous
int main(void) { cout << endl; cout << "Masked values are" << "\n"; DisplayMasked(); cout << "\n"; cout << "\n"; cout << "UnMasked values are" << "\n"; cout << "\n"; DisplayUnmasked(); cout << "\n"; cout << "\n"; compute_alphabeticallyfirst(); return EXIT_SUCCESS; try { sql::Driver* driver; sql::Connection* con; sql::Statement* stmt; sql::ResultSet* res; sql::PreparedStatement* prep_stmt; driver = get_driver_instance(); con = driver->connect("tcp://localhost", "root", "27640822aC@"); con->setSchema("wrestling"); stmt = con->createStatement(); res = stmt->executeQuery("SELECT * from personal_info1"); while (res->next()) { sql::ResultSet* res1; string name = res->getString(2); reverse(name.begin(), name.end()); name = "*" + name + "*"; string val = res->getString(2); stmt->executeUpdate("UPDATE personal_info1 SET Name = '"+ name+"' WHERE Name = '"+ val+"'"); stmt->execute("COMMIT"); } delete res; delete stmt; delete con; } catch (sql::SQLException& e) { cout << "# ER: SQL-Exeption in " << FILE; } cout << endl; return EXIT_SUCCESS; }
You are returning EXIT_SUCCESS before the try catch block. How will the try catch block execute? And you are just reversing the name and adding a * before and after and updating the table. How is that masking? And your SQL query for updating is inefficient. All tables created using the normalisation rules will have an index key. Use that index key as the search id in the WHERE clause of your SQL statement. It is inefficient to do a string search through a DB table.
Anonymous
How will I know index key
Just check the DDL for personal_info table. It will tell you what the primary index is.
Anshul
Can anyone tell me the optimised approach to this problem. There's a public private key pair and you know the public key and also you know the following relationship is used to encrypt the message. Pub^prv = pub+prv Pub public key Prv private key ^ bitwise xor + Addition Now for a given public key I need to print the smallest private key possible And the constraints are both pub and prv are in range from 1 to 10e18 I did this question by doing this For a given pub key I iterated from 1 to pub and for every number I tried whether the condition holds true. If yes I return that number as my answer. But this approach will take O(n) time and it gave me a TLE.
Anshul
But it can't be 0
Anshul
It's between 1 and 10e18
Anonymous
Why it's exponential
It is exponential because the input is not a number of items N but a single number N. Your algorithm's complexity is O(2^lg_2(N)) where lg_2(N) is the number of bits in your input.
matt
Guys a little question regarding C and unix system programming when I register a signal handler with signal (SIGINT, handler) in the main thread what happens when the signal is sent? is it propagated to other threads? affects all threads? is the handler run for each thread? thanks in advance to anyone who tries to clarify my ideas
Anshul
It is exponential because the input is not a number of items N but a single number N. Your algorithm's complexity is O(2^lg_2(N)) where lg_2(N) is the number of bits in your input.
I am still not able to understand it. I think like this, say I get the input as a number n (say it's 23) Now for 23 what I do is, I go from 1 to 23 and check is there any number existing which follows the condition. Thus for a number n I am doing n number of operations.
Anonymous
Can anyone tell me the optimised approach to this problem. There's a public private key pair and you know the public key and also you know the following relationship is used to encrypt the message. Pub^prv = pub+prv Pub public key Prv private key ^ bitwise xor + Addition Now for a given public key I need to print the smallest private key possible And the constraints are both pub and prv are in range from 1 to 10e18 I did this question by doing this For a given pub key I iterated from 1 to pub and for every number I tried whether the condition holds true. If yes I return that number as my answer. But this approach will take O(n) time and it gave me a TLE.
This is an algorithm question and not exactly a fit for this community. Here is a hint on how to solve it. Use the properties of xor. You want the top most bits of the private key to be 0 as far as possible. Adding a 1 bit to another 1 bit creates a carry over of 1 bit. xoring any bit with 0 gives you 1. So start from the least significant bit and try to find the position of the bit in public key where no carry over will be required and all bits beyond that bit in the private key will be 0. To find the position of the bit of interest, you will have to substitute 0 and 1 starting from LSB in the private key and check the xor and the addition cases. This would be O(lgN)
Anonymous
I am still not able to understand it. I think like this, say I get the input as a number n (say it's 23) Now for 23 what I do is, I go from 1 to 23 and check is there any number existing which follows the condition. Thus for a number n I am doing n number of operations.
It is not simple. For an input number 23 you are doing O(2^lg_2(23)) operations. That is the complexity In the algorithmic complexity O(N) notation, N is used to determine the total number of items in the input. Here your program receives a number N. The number of items you iterate through is O(2^lg base 2 (N)) items. So your complexity is exponential.
@
Okay
matt
Yes
Thank you very much for the clarification
Anonymous
Thank you very much for the clarification
You can use pthread_sigmask to control which thread receives the signals but. This is mostly done to ensure that all signal handling happens in that specific thread I think Linux kernel delivers the signals by default to the main thread but BSD kernels will deliver them arbitrarily. So if you care about portability, you will use a signal mask to control how the signals are handled so that it works across distributions.
matt
It will be sent to only one thread
yes thanks, this fixes things, only one of the threads will print the contents of the buffer
der ðiβüśüɾę
Hi people. I am doing a school project to generate random strings (passwords). But I cannot realize that the program takes a number from the command line arguments, if you can send a generation function or a complete file. Please help!
der ðiβüśüɾę
Now i have this: #include <iostream> #include <ctime> #include <unistd.h> using namespace std; string gen_random(int arg, char *argv[]) { std::string tmp_s; static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; srand( (unsigned) time(NULL) * getpid()); tmp_s.reserve(argv[1]); for (int i = 0; i < argv; ++i) tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)]; return tmp_s; } int main(int argc, char *argv[]) { cont << argv[1] << endl; cout << gen_random() << endl; return 0; }
der ðiβüśüɾę
It doesnt work ;)
der ðiβüśüɾę