Alex
ok, I am wrong. I thought strtok does not modifiy string. you can`t put strtok before if because it can return NULL pointer
Igor🇺🇦
Is msvc actually up to date there?
There is a newer version that was released on November 10 with Visual Studio 2019 16.8 ( like 2 days ago) that it isn't there. But compiler that was released with 16.7 is.
Anonymous
How to print every word of a string individually like the first word when we want similarly the second word when we want
Google "How to print every word of a string individually in + (language)" I'm pretty sure there's atleast a website which has the code and explains how it's done.
Anonymous
Hello, can anyone tell me why this loop does not terminate no matter what I enter?
Anonymous
#include <iostream> using namespace std; int main() { char ch; while (cin) { cin >> ch; } return 0; }
Anonymous
Ok thank
Anonymous
Putting a not operator before the cin causes the program to terminate without input. Please why?
Anonymous
Figured what is needed. Got to use a nested selection loop to decide when the program should terminate in the case where the expression for the while statement is just cin.
Anonymous
#include <iostream> using namespace std; int main() { char ch; while (cin) { cin >> ch; if (ch == '.') return 0; } return 0; }
Anonymous
#include <iostream> using namespace std; int main() { char ch; while (cin) { cin >> ch; if (ch == '.') return 0; } return 0; }
Just realized that break statement would be most appropriate for the if selection as the return forces the program to terminate within the while loop hence external statements ignored.
Anonymous
Well, probably because the evaluation of !cin is false as the condition suggests that the action statements not being of the input stream variable cin. If I use cout as the while statement, everything works just fine.
DC
i am facing these errors in codeforces
DC
You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20
DC
#include<iostream> using namespace std; int main (){ int n,m; int k,a,b; cin>>n; int A[n]; for(int i =0;i<n;i++){ cin>>A[i]; } cin>>m; int B[m]; for(int i =0;i<m;i++){ cin>>B[i]; } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ k =A[i]+B[j] ; a=0; b=0; for(int c=0;c<n;c++){ if(k!=A[c]){ a++; } } for(int d=0;d<m;d++){ if(k!=B[d]){ b++; } } if(a==n&&b==m){ cout<<A[i]<<" "<<B[j]; return 0; } } } return 0; }
Naman
You should Use pastebin or alternatives to post the code.
Naman
Instead of posting full code here, you should paste it to pastebin / privatebin and share the link here. Google pastebin, if you still don't understand
Luca
Hello guys, just a question about advanced programming. I would like to create a class made up by a vector of threads, this class has to be a method that allow me to launch a new thread by specifing a function to e executed like argumeent
Luca
so how to pass a function like parameter to another function?
Fox
Use pastebin for your code, then share the link
Igor🇺🇦
so how to pass a function like parameter to another function?
The easiest and the most generic way IMHO is using std::function https://en.cppreference.com/w/cpp/utility/functional/function
Anonymous
You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20
/report homework
Winkee
/get gcc9
Anonymous
/report homework
I mean i sometimes post homework but this bro just simply copy paste his asignment
Anonymous
I mean i sometimes post homework but this bro just simply copy paste his asignment
That question was like those asked in written interview exams..
Anonymous
You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20You are given an array A, consisting of n positive integers a1,a2,…,an, and an array B, consisting of m positive integers b1,b2,…,bm . Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B . For example, if A=[2,1,7] and B=[1,3,4], we can choose 1 from A and 4 from B, as number 5=1+4 doesn't belong to A and doesn't belong to B. However, we can't choose 2 from A and 1 from B, as 3=2+1 belongs to B . It can be shown that such a pair exists. If there are multiple answers, print any. Choose and print any such two numbers. Input The first line contains one integer n (1≤n≤100) — the number of elements of A . The second line contains n integers a1,a2,…,an (1≤ai≤200) — the elements of A . The third line contains one integer m (1≤m≤100) — the number of elements of B . The fourth line contains m different integers b1,b2,…,bm (1≤bi≤200) — the elements of B . It can be shown that the answer always exists. Output Output two numbers a and b such that a belongs to A, b belongs to B, but a+b doesn't belong to nor A neither B . If there are multiple answers, print any. Examples Input Copy 1 20 2 10 20 Output Copy 20 20
Why not just pick the largest in each?
gulshan
Helo
Mandelbröt
/get
Mandelbröt
/get cpp guide
Mandelbröt
Thanks
Pavel
Is there any analog to defining a macro PR(m,e) perror(m); exit(e)?
Alex
function
Alex
other preprocessors
Pavel
I mean standard library function
Pavel
How errors should be handled?
Alex
assert_perror
Anonymous
Hello
Anonymous
I have a problem in dynamic memory allocated array which I cant fix
Anonymous
Any help please?
Vlad
Me neither
Vlad
So show a gd code
Anonymous
Can I take a picture and send it here?
Vlad
Vlad
It aint that hard to ctrl+c ctrl+v your code to it, is it?
Anonymous
Why you so rude
Vlad
Why you so rude
It's C++ chat and I'm russian what did ya expect? Flowers?
olli
Why you so rude
Because you asked "meta" questions twice. If you want help show us your problem and read the rules
RC
Hey, does anyone know the meaning of this (') in flowchart like there? salary=salary +(items ' 8000)
RC
U know what does that mean ( ' )??
RC
Omg it was this * I didn't see it well
Anonymous
Hello am new here
Anonymous
Pls I have question in c++ can any one help
Anonymous
Kindly suggest me a book for c programming
Vlad
The biggest question of all why do you store pointers in these structs?
Nils
Does function overloading create an overhead?
Igor🇺🇦
Does function overloading create an overhead?
Overloaded method is the same as creating any other method.
RJ
Is there a way to get sane warnings and errors in c++?
RJ
Define sane.
Not 184 lines of std templates and only show where the actual error is
Talula
Not 184 lines of std templates and only show where the actual error is
I know it's confusing for many people that C doesn't show where the error actually is, shows something else but it's due to how original C was designed, it wasn't designed with \n in mind it was designed with ; to terminate the line.
Talula
Not 184 lines of std templates and only show where the actual error is
So based on the old compiler ideas the C that is what all the compilers are following, C++ Builder has a better at displaying errors but it sucks in library, it's not free and it doesn't support half the things in life...
Anonymous
Anyone know OS and embedded systems very well? I have exam in a hour, I need some help please 🛑🛑
𝖳𝗁𝖾 𝖠𝗅𝗀𝗈𝗋𝗂𝗍𝗁𝗆 𝖭𝗂𝗇𝗃𝖺 ⚪♛
𝖳𝗁𝖾 𝖠𝗅𝗀𝗈𝗋𝗂𝗍𝗁𝗆 𝖭𝗂𝗇𝗃𝖺 ⚪♛
/get
Anonymous
Os alone
Can I DM u?
Sky
No