Anonymous
Not qsort, std::sort
The "atpbored" channel is way better at these things than I am...
Anonymous
The "atpbored" channel is way better at these things than I am...
https://t.me/atpbored/96 Using void main just confirms that the person knows neither C nor C++
Anonymous
My mistake.
Sehab
Rummy card game using linked list in C Or the algorithm anything... Please help
Anonymous
I'm learning now... 😔
It's ok But you either learn a language or algorithms
Anonymous
It's ok But you either learn a language or algorithms
So , should I first learn the language and then start algorithms ? Currently I'm learning both at the same time..
Anonymous
Happy to here
ken
Hello. Good day everyone. Is it possible to instantiate an object inside a loop just once throughout the lifetime of the program? If it is, please what concepts guides it so I can read it up for better understanding. Thank you.
Igor🇺🇦
So , should I first learn the language and then start algorithms ? Currently I'm learning both at the same time..
It's will help to better understand algorithms if you know at least one programming language. Learning algorithms without any programming experience is too abstract. IMHO.
soso
Hello, can anyone help me c++
Pavel
Ok, so suppose I'm learning a new language, at what point could I say that i know the language?
Well, there are several levels of knowing a language, and not sure if someone can claim that they fully know C++ for example - Knowing basic syntax allowing to write applications - Knowing most of the syntax, most important to know caveats and standard approaches used in the language - Knowing underlying logic behind the language features, knowing how most of the things are being implemented, knowing important differences between language versions ... There are more levels but I can't describe them because I far from getting there In your case, I guess knowing basic syntax and some basic approaches used in the language should be enough to start learning algorithms
Anonymous
does std::string_view::remove_prefix() invalidate an iterator produced by std::string_view::begin() from before?
Anonymous
mov $22, %rax
How can I compile a C library with gcc?
Al
use -c option
Al
the output will be an object file
Al
you can link the object to the main after
Al
you can always gcc al toghter .. gcc mainprog.c library.c -o result
Igor🇺🇦
does std::string_view::remove_prefix() invalidate an iterator produced by std::string_view::begin() from before?
I couldn't find sources. But I don't think it's necessary. string_view does not alter original object, so old begin will point to old still valid place. I don't see the reason for iterator to be invalidated. But I can't give you a certain answer. Maybe I'm missing something.
Anonymous
I couldn't find sources. But I don't think it's necessary. string_view does not alter original object, so old begin will point to old still valid place. I don't see the reason for iterator to be invalidated. But I can't give you a certain answer. Maybe I'm missing something.
[string.view.template] paragraph 2 For a basic_string_view str, any operation that invalidates a pointer in the range [str.data(), str.data() + str.size()) invalidates pointers, iterators, and references returned from str’s member functions.
Vlad
How can I compile a C library with gcc?
gcc -c -o out.o out.c ar rcs libout.a out.o
Vlad
If you want to build it as static library
Anonymous
Which button
Anonymous
You are given a sequence A1,A2,…,AN. Find the maximum value of the expression |Ax−Ay|+|Ay−Az|+|Az−Ax| over all triples of pairwise distinct valid indices (x,y,z). Input The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N. The second line contains N space-separated integers A1,A2,…,AN. Output For each test case, print a single line containing one integer ― the maximum value of |Ax−Ay|+|Ay−Az|+|Az−Ax|. Constraints 1≤T≤5 3≤N≤105 |Ai|≤109 for each valid i Subtasks Subtask #1 (30 points): N≤500 Subtask #2 (70 points): original constraints Example Input 3 3 2 7 5 3 3 3 3 5 2 2 2 2 5 Example Output 10 0 6 Explanation Example case 1: The value of the expression is always 10. For example, let x=1, y=2 and z=3, then it is |2−7|+|7−5|+|5−2|=5+2+3=10. Example case 2: Since all values in the sequence are the same, the value of the expression is always 0. Example case 3: One optimal solution is x=1, y=2 and z=5, which gives |2−2|+|2−5|+|5−2|=0+3+3=6.
Anonymous
#include <bits/stdc++.h> using namespace std; void fxn() { int flag=0; int small,big; unsigned short int n; cin>>n; int num[n]; for(;flag<n;flag++) { cin>>num[flag]; if(flag==0){small=num[0];big=num[0];} if(big<num[flag]) {big=num[flag];} if(small>num[flag]) {small=num[flag];} } flag=0; int result=0,stuff; for(;flag<n;flag++) { stuff=abs(small-big)+abs(big-num[flag])+abs(small-num[flag]); if(result<stuff) { result=stuff; } } cout<<result<<endl; } int main() { int testcase=1; cin>>testcase; for(int i=0;i<testcase;i++) { fxn(); } }
Anonymous
why my code is not accepted by codeshef i am beginner 😐
Aakash
does std::string_view::remove_prefix() invalidate an iterator produced by std::string_view::begin() from before?
Looks though!! Run few times to check last string🤪 — #include <iostream> #include <string_view> using namespace std; int main() { std::string x = " this looks funny"; std::string_view y = x; int i=0; std::string_view::iterator it; cout << "String\t: " << y.data() <<endl; for(it = y.begin(); it != y.end(); it++) { cout << "Test:"<<i++ <<"\t: " << *it \ //<< "\tstring: " << y.data() <<endl; y.remove_prefix(*it); } cout << "Last-String\t: " << y.data() <<endl; return 0; } 🙃😄
Code Commander
/notes
Anonymous
/get india
Anonymous
/get learn
Anonymous
Anonymous
/get Mars
Hmaada
/rules
Hmaada
Hi everyone can I have some helps about conversion type
Hmaada
It would be about what is the "biggest" type that we couldn't convert and what is the "smallest" type that we could convert to all other types or cast it
αмιянσѕѕєιη
Hey guys I've been learning html and my friend told me i can declare variables in it but he didn't tell me how. can you help me? thanks a lot
Diego
Sorry my guy that's off topic for this group, but you can look it up on google
αмιянσѕѕєιη
Anonymous
#include <iostream> #include <math.h> using namespace std; class calculat { double A,B,C; public: void for_two_value() { cout<<"enter the first value :"; cin>>A; cout<<"enter the second value :"; cin>>B; } void for_single_value() { cout<<"enter the value :"; cin>>C; } double add() { return A+B; } double sub() { return A-B; } double mul() { return A*B; } double div() { if (B==0) { cout<<"division by zero is :"<<endl; return INFINITY; } else { return A/B; } } double square_root() { return sqrt(C); } double cube() { return C*C*C; } }; int main() { char choice; int C; calculat cal; cout<<" A for addition \n S for subtraction \n"; cout<<" M for multiplication \n D for division\n"; cout<<" Z for square root\n C for cube"; cout<<"\nTO start enter '1' or to stop '0' :"; cin>>C; jadu: while(C==1){ cout<<"enter what to do ::"; cin>>choice; switch(choice) { case 'A': cal.for_two_value(); cout<<"Result :"<<cal.add()<<endl<<"\n"; break; case 'M': cal.for_two_value(); cout<<"Result :"<<cal.mul()<<endl<<"\n"; break; case 'S': cal.for_two_value(); cout<<"Result :"<<cal.sub()<<endl<<"\n"; break; case 'D': cal.for_two_value(); cout<<"Result :"<<cal.div()<<endl<<"\n"; break; case 'Z': cal.for_single_value(); cout<<"Result :"<<cal.square_root()<<endl<<"\n"; break; case 'C': cal.for_single_value(); cout<<"Result :"<<cal.cube()<<endl<<"\n"; default : goto jadu; cout<<"enter the approprieat choice which is given ....\n"; } } return 0; }
Igor🇺🇦
#include <iostream> #include <math.h> using namespace std; class calculat { double A,B,C; public: void for_two_value() { cout<<"enter the first value :"; cin>>A; cout<<"enter the second value :"; cin>>B; } void for_single_value() { cout<<"enter the value :"; cin>>C; } double add() { return A+B; } double sub() { return A-B; } double mul() { return A*B; } double div() { if (B==0) { cout<<"division by zero is :"<<endl; return INFINITY; } else { return A/B; } } double square_root() { return sqrt(C); } double cube() { return C*C*C; } }; int main() { char choice; int C; calculat cal; cout<<" A for addition \n S for subtraction \n"; cout<<" M for multiplication \n D for division\n"; cout<<" Z for square root\n C for cube"; cout<<"\nTO start enter '1' or to stop '0' :"; cin>>C; jadu: while(C==1){ cout<<"enter what to do ::"; cin>>choice; switch(choice) { case 'A': cal.for_two_value(); cout<<"Result :"<<cal.add()<<endl<<"\n"; break; case 'M': cal.for_two_value(); cout<<"Result :"<<cal.mul()<<endl<<"\n"; break; case 'S': cal.for_two_value(); cout<<"Result :"<<cal.sub()<<endl<<"\n"; break; case 'D': cal.for_two_value(); cout<<"Result :"<<cal.div()<<endl<<"\n"; break; case 'Z': cal.for_single_value(); cout<<"Result :"<<cal.square_root()<<endl<<"\n"; break; case 'C': cal.for_single_value(); cout<<"Result :"<<cal.cube()<<endl<<"\n"; default : goto jadu; cout<<"enter the approprieat choice which is given ....\n"; } } return 0; }
What's the point of this long post?
Benjamin
Texs for meting you
Benjamin
& iam hapy
Diego
#include <iostream> #include <math.h> using namespace std; class calculat { double A,B,C; public: void for_two_value() { cout<<"enter the first value :"; cin>>A; cout<<"enter the second value :"; cin>>B; } void for_single_value() { cout<<"enter the value :"; cin>>C; } double add() { return A+B; } double sub() { return A-B; } double mul() { return A*B; } double div() { if (B==0) { cout<<"division by zero is :"<<endl; return INFINITY; } else { return A/B; } } double square_root() { return sqrt(C); } double cube() { return C*C*C; } }; int main() { char choice; int C; calculat cal; cout<<" A for addition \n S for subtraction \n"; cout<<" M for multiplication \n D for division\n"; cout<<" Z for square root\n C for cube"; cout<<"\nTO start enter '1' or to stop '0' :"; cin>>C; jadu: while(C==1){ cout<<"enter what to do ::"; cin>>choice; switch(choice) { case 'A': cal.for_two_value(); cout<<"Result :"<<cal.add()<<endl<<"\n"; break; case 'M': cal.for_two_value(); cout<<"Result :"<<cal.mul()<<endl<<"\n"; break; case 'S': cal.for_two_value(); cout<<"Result :"<<cal.sub()<<endl<<"\n"; break; case 'D': cal.for_two_value(); cout<<"Result :"<<cal.div()<<endl<<"\n"; break; case 'Z': cal.for_single_value(); cout<<"Result :"<<cal.square_root()<<endl<<"\n"; break; case 'C': cal.for_single_value(); cout<<"Result :"<<cal.cube()<<endl<<"\n"; default : goto jadu; cout<<"enter the approprieat choice which is given ....\n"; } } return 0; }
/report
Benjamin
Pleas writ sam gem patern
Aakash
nah. your code is quite wrong. remove_prefix takes the number of characters to move the view forward by. your remove_prefix(*it) is passing it anything from 32 (ascii ' ') to 121 (ascii 'y'), which is undefined behaviour since it is greater than the length of the string_view. in the cout part dereferencing the iterator produces a char and the y.data() printing is commented for some reason.
You are your best judge!! Manipulate your size😜 — #include <iostream> #include <string_view> using namespace std; int main() { std::string x = " this looks funny"; std::string_view y = x; std::string z {y}; cout << "String: " <<y.data() <<endl; cout << "Size : " <<y.size() <<endl; std::string_view::iterator it; int i=0; for(it = y.begin(); it!= y.end(); it++) { cout <<"Test-1: " <<i <<":" <<*it //<<"String: " <<i <<":" <<y.data() //## <<endl <<"Size-1: " <<i <<":" <<z.size() <<endl; //y.remove_prefix(*it); //#unhide# //y.remove_prefix(i); //#unhide# i++; } //////—-either-of-above-&-below—- //const int k=y.size(); /* for(int j=0; j<y.size(); j++) { cout <<"Test-1: " <<j <<":" <<y.data() <<endl <<"Size-1: " <<j <<":" <<y.size() <<endl; y.remove_prefix(j); } */ cout << "Last-Str1\t: " <<y.data() <<endl; cout <<"XX—————" <<endl; i =0; cout <<"String: " <<z.data() <<endl; cout <<"length: " <<z.size() <<endl; std::string::iterator itx; for(itx = z.begin(); itx != z.end(); itx++) { cout <<"Test-2: " <<i <<":" <<*itx <<"String: " <<i <<":" <<z.data() <<endl <<"Size-2: " <<i <<":" <<z.size() <<endl; z.erase(i, 1); i++; } cout <<"Last-Str2\t: " <<z.data() <<endl; cout <<"\nTypeX:"<<typeid(x.data()).name() <<"\nTypeY:"<<typeid(y.data()).name() <<"\nTypeZ:"<<typeid(z.data()).name() <<endl; return 0; } 🙃🙃
Anonymous
/report
Anonymous
Pleas writ sam gem patern
It's a simple program
Eturnus
What us white space character 8n c programming
Jhagrut
/notes
Yuval
#awesomeness
z
#ossu
z
#bro
z
#mcve
Anonymous
is there any way to convert java code to c++?
AbdurRehman
Any c++ expert here..need a bit advice about a collage project
Jyson
Hi
Anonymous
Hi
Massi
Guys i need your help
Massi
what does this code mean
Massi
c = getchar() ! = EOF ;