B121065_Swoyam Siddharth Nayak
so they do removed pairs, but i was confused that what if a number is present three times
Anonymous
i tried, but i want the answer in BIT MANIPULATION METHOD
Which part of your solution should be in bit manipulation? The comparison ?
B121065_Swoyam Siddharth Nayak
Abhishek
so they do removed pairs, but i was confused that what if a number is present three times
In xor operation that no. eliminates only if that no. present even times
B121065_Swoyam Siddharth Nayak
Abhishek
Instead of searching ans or solutions think for some time and analysis the solution and this will increase your problem solving skills
Viprr
Ano.. ===6.. Mtlb su thay
Anonymous
finding the unique number
I can think of a solution , But , worst case will be O(n^2)
Anonymous
😅😅
Basically , a for loop inside another for loop where it compares the array elements . If the two elements are same , then the inside loop breaks and command goes to the outside loop and it repeats. If no elements are same , then stores that specific element in another array. Something like that.
B121065_Swoyam Siddharth Nayak
/warn offtop
what do you mean by offtop??
Viprr
Soory
Anonymous
what do you mean by offtop??
Google the meaning of the word
B121065_Swoyam Siddharth Nayak
Viprr
/warn
Anonymous
what’s google?
/warn google google
B121065_Swoyam Siddharth Nayak
/warn offtop
i didn't understand why warning, i asked a doubt
Anonymous
i didn't understand why warning, i asked a doubt
Read the rules Computer architecture is not on topic here
B121065_Swoyam Siddharth Nayak
Read the rules Computer architecture is not on topic here
kya bhaiya, you should support the beginners naa...
Abhishek
Read the rules Computer architecture is not on topic here
That question is not of computer architecture
Anonymous
That question is not of computer architecture
> gate > Not computer architecture
Abhishek
> gate > Not computer architecture
He mistyped it should be xor operation instead of gate that's understood
Anonymous
Ok I get it Still he broke a rule asking to solve for him
Anonymous
But I removed the warn
B121065_Swoyam Siddharth Nayak
Thank you
Dima
what the heck
Anonymous
Thank you
Use English
Aura
Thank you
Thankyou is pretty much English only
B121065_Swoyam Siddharth Nayak
Thankyou is pretty much English only
no, i edited after his warning
Aura
Okay its fine then
Anonymous
Keeahnoo: I need help making a c++ program where it asks a password, and everytime its asking a password and the password is wrong. It returns 2 numbers. Number of position that is correct , and the number of letters that were correct but in an incorrect position. If the password entered is correct, it returns correct. The given password is "icpc" If the user types "accp" its returns number 1 and 2. As there is 1 correct position, and 2 correct letters but incorrect position #include <iostream> using namespace std;    int main(){​​​​     string passC = "icpc", passA;       for(int i=50; i >= 1;i--){​​​​     cout << "Type the password ";     cin >> passA;     if(passA != passC){​​​​         cout << "wrong answer \n" << "attemps left " << i<< "\n\n";              }​​​​     else if (passA == passC){​​​​         cout << "Correct";         break;     }​​​​     }​​​​      }​​​​ This is the code I made but its lacking. And Im too dumb to complete it. And if I type cacp its returns the number 0 and 3 Make sense? Thank you for someone who will help.
B121065_Swoyam Siddharth Nayak
how can you use string data type without including string header file
B121065_Swoyam Siddharth Nayak
#include<iostream> #include<string> using namespace std; int main(){ string passC = "icpc", passA; for(int i=50; i >= 1;i--){ cout << "Type the password "; cin >> passA; if(passA != passC){ cout << "wrong answer \n" << "attemps left " << i<< "\n\n"; } else if (passA == passC){ cout << "Correct"<<endl; break; } } return 0; } DO THIS AND IT WOULD RUN PERFECT, It ran perfectly on my system
Anonymous
Gimme some time....
Thank you my friend.
B121065_Swoyam Siddharth Nayak
#include<iostream> #include<string> using namespace std; int main(){ string passC = "icpc", passA; int correctpos=0; int correct=0; for(int i=50; i >= 1;i--){ cout << "Type the password "; cin >> passA; if(passA != passC){ for(int i=0;i<passA.size();i++){ if(passA[i]==passC[i]){ correctpos++; } } for(int i=0;i<passA.size();i++){ for(int j=0;j<passC.size();i++){ if(passC[j]==passA[i]){ correct++; } } } correct=correct-correctpos; cout << "wrong answer \n" <<correctpos<<" "<<correct<<endl<<"attemps left " << i<< "\n\n"; } else if (passA == passC){ cout << "Correct"<<endl; break; } } return 0; } acc to me this should be the answer
B121065_Swoyam Siddharth Nayak
for(int i=0;i<passA.size();i++){ if(passA[i]==passC[i]){ correctpos++; } } in above loop i counted numper of characters present at correct position for(int i=0;i<passA.size();i++){ for(int j=0;j<passC.size();i++){ if(passC[j]==passA[i]){ correct++; } } } here I counted the number of correct characters
B121065_Swoyam Siddharth Nayak
for that i subtracted total number of characters at current position from total number of correct characters
Jasur Fozilov 🐳
/get
Anonymous
Hi
あおい ハート
Can't i define the function inside the main function to lower the scope of function??
あおい ハート
If it's C++ you can create a lambda
Is it possible without using lambda function??
Pavel
Is it possible without using lambda function??
No, unfortunately. But lambdas should be the same fast as usual functions, if you don't capture anything and store them as auto. Just a little bit more verbose.
Pavel
Sir what is std::function function reference is it similar to lambda functions??
std::function is a wrapper for callable objects (function pointers, lambdas, probably something else that has operator() and passes other requirements). It can be used to store this callable object for longer period of time, for example you can make a lambda and store it outside of the function where it was created to call at some point later. Also std::function is heavier than just lambda, so if you don't want to store the lambda outside the scope where you created it, then no need to convert it to std::function.
Anonymous
#include <iostream> struct pair { int right; int wrong; }; pair validate(const std::string& A, const std::string& B) { int right = 0, wrong = 0; std::string f; pair p; for (unsigned int i = 0; i < A.length(); i++) { f=B[i]; if (A[i] == B[i]) { right += 1; } else if (A.find(f)!= std::string::npos){ wrong += 1; } } p.right = right; p.wrong = wrong; return p; } int main() { std::string passC = "icpc", passA; for(int i=50; i >= 1;i--) { std::cout << "Type the password: "; getline(std::cin, passA); std::cin.clear(); if(passA != passC){ std::cout << "Wrong answer \n" << "Attemps left: " << i<< "\n\n"; pair p = validate(passC, passA); std::cout << p.right << " right positions, " << p.wrong << " wrong positions" << std::endl; } else if (passA == passC) { std::cout << "Correct" << std::endl; break; } } }
Anonymous
Can someone explain to me how this code works?
Anonymous
Every line please.
Anonymous
im trying to use "BCryptOpenAlgorithmProvide()" function but i got error "identifire is undefined" can anyone help me pls?
Anonymous
that's my code """ #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <bcrypt.h> #include <winternl.h> #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L) int main(){ BCRYPT_ALG_HANDLE cAlgHandle; NTSTATUS algProvider = BCryptOpenAlgorithmProvide(&cAlgHandle, BCRYPT_SHA256_ALGORITHM, NULL, 0); ""
Anonymous
Oh lol.. Im realy idiot Im was searching for the solution for about 2 hours, Thanks a lot man
.
Is there any way to find a proper implementation of any data structure in c++
Anonymous
Need a little help, I am using a library, that takes file path as char* Restarted C++ after a long time, can anyone please tell me how can i do it?
Vaishnav
Can someone give all c programming notes
Sarthak
#include <iostream> using namespace std ; int main () { int choice ; do { cout << " 0. QUIT\n 1. PLAY \n" ; cin >> choice ; switch ( choice ); { case 0: cout << " get lost\n " ; return 0 ; case 1: cout << " lets play the game\n" ; break ; } } while (choice != 0);
Sarthak
My switch statement shows error
Talula
My switch statement shows error
Remove semicolon after switch.
Sarthak
Okay thanks
تاریکانون
C program to reverse a string ...
Anonymous
Diego
C program to reverse a string ...
string.Reverse(yourstring)
Diego
If it doesn't compile, then there;s something wrong with your instalation
Diego
You'll probably have to delete System32 or something for it to work
olli
Can someone give all c programming notes
http://www.iso-9899.info/n1570.html