Anonymous
The Curious Cat
Devjit
/get cbook
Erick
/get
Anonymous
Bumpy
hello eve , its ok to ask about BASH COMMANDS?
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.
Suka
Official hooligan of Pius XII
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
Apk
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
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
Hirrolot
Anonymous
similar to operator precedence right
Anonymous
?
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
Anonymous
Anonymous
i am just going to give it a shot 😇
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
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
Apk
Anonymous
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
Anonymous
Anshul
Anyone please tell..
#define ll long long
ll ans=1ll;
Anshul
What is the meaning of writing 1 ll
Vlad
Anshul
Why don't just write 1
Vlad
Vlad
If it was an integer it would overflow
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
Anshul
In c++ implicit typecasting isn't done?
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
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
Vlad
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
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