Anonymous
Andrew
/get awesomeness
ohh i feel like stupid now
Devjit
/get cbook
Erick
/get
Anonymous
/get awesomeness
O.o welcome back
Anonymous
O.o welcome back
Thanks 🙂
Bumpy
hello eve , its ok to ask about BASH COMMANDS?
klimi
hello eve , its ok to ask about BASH COMMANDS?
it is a little offtopic, better to ask in the offtopic group
klimi
#ot
Official hooligan of Pius XII
Is there an easy way to capture arrow keys as input in C++? Or should I give up with them and use simple WSAD with std::cin? I was reading some articles but none of the anwsers was satisfying. Note that I need the program to work on each platform: Windows, Linux and Mac.
Official hooligan of Pius XII
Suka
okay thanks
you're welcome
Anonymous
#include<stdio.h> int main() { int i,j,k; printf("enter the no. of rows you want to print "); scanf("%d",&k); for(i=1;i<=k;i++) { for(j=1;j<=i;j++) { printf("%d",k); } printf("\n"); } printf("enter the no. of rows you want to print "); scanf("%d",&k); for(i=1;i<=k;i++) { for(j=1;j<=i;j++) { printf("%d",k); } printf("\n"); } return 0; } I want this loop to be continued so which loop should I use for/while and where to use The output I want 2 22 Then again I press 2 2 22 Then again 2 22 This loop I want
Anonymous
I am a beginner at c++ may a get guider🙏please
Pavel
I am a beginner at c++ may a get guider🙏please
Hi, it works a bit differently here. If you have a problem with C++ or a question, and can't google solution to it, you can ask here and people will try to help. Note that it should be a clear question. E.g. if you want to understand why your code works not as intended you can post the code (using code pasting service like pastebin) together with explanation what the code does wrong (and what's the expected behavior of your code).
Anonymous
i am learning stack,queue topic in c I just need some idea in which i can apply these things (I need the ideas in beginner level )
Anonymous
similar to operator precedence right
Anonymous
?
Anonymous
similar to operator precedence right
in which i am going to implement stack right?
Hirrolot
The operator precedence is fixed here
Hirrolot
ALU is to be implemented with the stack
Anonymous
ALU?
Talula
ALU?
Arithmetic-Logic Unit, now a part of processor but originally it use to come as a separate math-coprocessors.
Anonymous
ALU is to be implemented with the stack
Thanks for the idea man 👍
Talula
Thanks for the idea man 👍
You understood what he said, I didn't understand.
Anonymous
You understood what he said, I didn't understand.
He said that ALU should me implemented along with stack
Anonymous
i am just going to give it a shot 😇
Talula
He said that ALU should me implemented along with stack
Err... you can't do that, what he is showing is simply how the calculator would work... so you use link list to separate things and work backwards, what ALU has got to do with it?
Talula
You could use recursion as well for it.
Hirrolot
Linked list is concrete data structure so it can represent the stack as well
Talula
Linked list is concrete data structure so it can represent the stack as well
Okay that is fine, but what ALU has got to do with it?
Hirrolot
ALU takes/puts operands from/onto the stack
Talula
ALU takes/puts operands from/onto the stack
ALU does calculations that is it... if main processor needs to calculate something it passes on that information to ALU and ALU returns the result that is it... nothing more.
Hirrolot
Yes
Vlad
any eg 😅
Once you encounter ( you make a push into your stack. And do pop once encounter )
Vlad
And check that the resulting size will be 0
Vlad
And that you don't pop on an empty stack
Apk
any eg 😅
(a+b)*c) - wrong ((a+b)*c) - right
Anshul
Anyone please tell.. #define ll long long ll ans=1ll;
Anshul
What is the meaning of writing 1 ll
Anshul
Why don't just write 1
Vlad
Why don't just write 1
consider 1ll << 33
Vlad
If it was an integer it would overflow
Anshul
consider 1ll << 33
1ll means, left shift 1 by 33??
Vlad
1ll means, left shift 1 by 33??
Same as (long long)1 << 33
Anshul
I have one question that if I think one integer, let's say "i" is in range of int. But somewhere I need to use "i*i" and I know that it will exceed limit of int
Anshul
So do I need to store i and i*i in long long
Anshul
Or I need to store only i*i in long long
Vlad
So do I need to store i and i*i in long long
You'd have to cast it to long long first
Anshul
In c++ implicit typecasting isn't done?
Vlad
In c++ implicit typecasting isn't done?
expression i * i will be calculated as int
Vlad
Then it's result would be stored in long long
Vlad
long long l = i * i;
Anshul
Ok so it's good that I either do typecasting or I make i as long long
Vlad
Ok so it's good that I either do typecasting or I make i as long long
Basically you should do it always while multiplying integers. You cast to the bigger type and check whether it overflowed over int_max or not. If it did then handle it accordingly
Vlad
As always it heavily depends on what you're doing and the guarantee that you've got on your input values
Vlad
But I'd rather avoid having silent UB in your code
Anshul
What is UB
Vlad
undefined behavior
Vlad
Signed integer overflow is a classy example
Anshul
I wrote a code for a problem. For smaller values it runs perfectly. But for larger values it just don't print anything even after taking so much time
Anshul
#include<iostream> #include<algorithm> using namespace std; #define ll long long int main () { ll l,r; cin>>l>>r; ll max_res=0; for(ll i=l;i<=r;i++) { for(ll j=i+1;j<=r;j++) { max_res=max(max_res,(i^j)); } } cout<<max_res; return 0; }
Vlad
What is it supposed to do?
Anshul
this code runs well for smaller values but when i put two values these, it just stops 79242383109441603 533369389165030783
Anshul
i^j is xor
Anshul
Given two integers l and r , your task is to find the maximum xor of two integers both of which lying between l and r inclusive.
Vlad
i^j is xor
I thought that you might have confused it as a raise to the power operator. Nvm