B121065_Swoyam Siddharth Nayak
so they do removed pairs, but i was confused that what if a number is present three times
B121065_Swoyam Siddharth Nayak
Abhishek
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
B121065_Swoyam Siddharth Nayak
B121065_Swoyam Siddharth Nayak
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.
Anonymous
Anonymous
B121065_Swoyam Siddharth Nayak
/warn offtop
what do you mean by offtop??
Anonymous
Viprr
Soory
Dima
B121065_Swoyam Siddharth Nayak
Viprr
/warn
B121065_Swoyam Siddharth Nayak
/warn offtop
i didn't understand why warning, i asked a doubt
B121065_Swoyam Siddharth Nayak
B121065_Swoyam Siddharth Nayak
Abhishek
Anonymous
Anonymous
Ok
I get it
Still he broke a rule asking to solve for him
Abhishek
Anonymous
But I removed the warn
B121065_Swoyam Siddharth Nayak
Thank you
Dima
what the heck
Anonymous
Aura
Thank you
Thankyou is pretty much English only
B121065_Swoyam Siddharth Nayak
Aura
Okay its fine then
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
B121065_Swoyam Siddharth Nayak
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
Anonymous
B121065_Swoyam Siddharth Nayak
for that i subtracted total number of characters at current position from total number of correct characters
Anonymous
Jasur Fozilov 🐳
/get
Anonymous
Hi
あおい ハート
Can't i define the function inside the main function to lower the scope of function??
Pavel
あおい ハート
あおい ハート
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);
""
olli
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++
Hanz
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
Sarthak
Okay thanks
تاریکانون
C program to reverse a string ...
Anonymous
z
Diego
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
Anonymous
olli