coal
instead of writing directly to fout <<, try making a stringstream and writing to it, then write this stringstream to the fout
Kevin
it's slow because << writes and flushes the file every single time
that's not the problem, he writes a few times, the problem is when the problem inputs are as big as 100,000 "seets"
coal
why don't you read the entire input at once and then parse it?
coal
it would make your program much faster
Kevin
ok I'll try
coal
yup
Mayur
Q. Write a programe in c++ to print the series of 1 4 9 16 ... 10 terms
神 ꜰʟᴀꜰꜰʏ
#include <iostream> using name space std; int main() { for (int i = 1; i < 11; i++) cout << i*i << " "; }
神 ꜰʟᴀꜰꜰʏ
Dunno, wrote in haste
Mayur
Dunno, wrote in haste
Didn't get it
神 ꜰʟᴀꜰꜰʏ
I meant that I wrote quickly, through the phone
Anonymous
Hello
Anonymous
Write a C program that allows a user to enter the upper limit of a series of ODD numbers, the displays all the ODD numbers within that range Someone help me with this pllz
Anmol
Write a C program that allows a user to enter the upper limit of a series of ODD numbers, the displays all the ODD numbers within that range Someone help me with this pllz
#include<stdio.h> void main() { int num,m =20,n=40; clrscr(); printf("Print Odd Numbers in a given range m to n:\n"); for (num = m; num <= n; num++) { if (num % 2 == 1) printf ("%d ", num); } getch(); }
Nomid Íkorni-Sciurus
Is it better to look for dependencies on the host system (ex: libcairo) or to build them along with the application? The fact is that setting up the environment on Windows is tedious and I wanted to create a cmake FindPackage target to download them and build them
MᏫᎻᎯᎷᎷᎬᎠ
.
Nils
Hey, any clue how to write a floor plan generator like this? https://epic-tereshkova-067226.netlify.app/ Are there any documentations or something on good practices to get that good results?
Anonymous
Could anyone please say which one is better job oriented in embedded field 1. Multimedia (Camera, Audio, Video) 2. Autosar Adaptive
Krishnaa
vector<vector<int>> merge(vector<vector<int>>& a) { sort(a.begin(), a.end()); int n=a.size(); for(int i=0; i<n; ){ if(i+1==n) break; else if(a[i][1]>=a[i+1][0]){ if(a[i][1]<a[i+1][1]) a[i][1]=a[i+1][1]; a.erase(a.begin()+i+1); n=a.size(); } else {i++;} } return a; }
Krishnaa
Look at this Merge Intervals code, it shows TLE for one last test case: 168/169 passed.
Krishnaa
Somebody help me to resolve TLE in LeetCode
.....
how to check validation in char
.....
?any body help
.....
c
.....
done i got it .
Krishnaa
You can change value of ma and n
Can u look up at my query, pls???
Krishnaa
?
That Merge intervals one
Abduool
Hi
Msd
Hi any soft copy for c ++ if yes please give link or file please Thanks in advance 👍
Anmol
This
Sorry I am unable to solve your query. But I think this can help 👇🏻👇🏻 class Solution { public: vector<vector< int>> merge(vector<vector< int>>& intervals) { vector<vector< int>> ans; sort(intervals.begin(),intervals.end()); vector< int> temp; temp=intervals[0]; for(auto it:intervals) { if(temp[1]>=it[0]) { temp[1]=max(temp[1],it[1]); } else { ans.push_back(temp); temp=it; } } ans.push_back(temp); return ans; } };
100$ website
watching a c++ advance tutorial he= the tutor! 17>>1 answer is 8 17>>2 answer is 4 how he knows the answers immediately, or do he have any method to get answer very fast? if someone know such method, please guide me through i would like to learn that
100$ website
17>>1 is the same with 17/2 17>>2 is the same with 17/4 note that these only apply to integer, that means no floating point number
i wanna learn how to know binary of any number without calculating it on pen and paper a video refrence would work well too
Alviro Iskandar
Alviro Iskandar
but shift >> 1, is the same with /2
Alviro Iskandar
that's what i know for integer
100$ website
Alviro Iskandar
ok lemme find it, will share here thank you!
i'll be looking forward for that as well
100$ website
17>>1 gets rid of the right-most bit,
and padding will be 0 in both left and right shift
coal
17>>1 is just moving the 5th bit to the 4th bit
coal
and the power of 2 before 16 is 8
coal
10001 (16+1) becomes 1000 (8)
Alviro Iskandar
17>>1 gets rid of the right-most bit,
if the second bit is set, it still there though
Alviro Iskandar
for ex: 3 >> 1 it's 0b11 after shift 0b1
Anonymous
Alviro Iskandar
the point is it shift 1 everything to the right
Alviro Iskandar
to get rid of lsb, it should be like this N & ~ 0b1
coal
3>>1 is 2
coal
or, hmm
Anonymous
to get rid of lsb, it should be like this N & ~ 0b1
Oh you're talking about flipping bits
Anonymous
coal
3>>1 is 2
nevermind, its 1
coal
11 is just 1 after getting rid of the right-most bit
coal
back to the question though
Alviro Iskandar
17>>1 gets rid of the right-most bit,
you said: > 17>>1 gets rid of the right-most bit, that is not true, to get rid of the right-most bit is: 17 & ~1
Anonymous
11 is just 1 after getting rid of the right-most bit
He's talking about "turning off" the lsb
coal
he changed the topic without answering the op, lol
Alviro Iskandar
who changed?
Alviro Iskandar
17>>1 is the same with 17/2 17>>2 is the same with 17/4 note that these only apply to integer, that means no floating point number
i am exactly saying how to calculate that very quickly by this mindset 17>>1 is the same with 17/2 17>>2 is the same with 17/4 that partially answers the op's question
coal
for example, if you wanted to get the binary for 129, you would add 1 and 128 (8th bit)
coal
which would result in 10000001
coal
when the number is not as close to another power of 2, you can get the largest power of 2 that doesn't go over the number, for example, to get the binary of 133, you need to get the largest power of 2 that doesn't go over 133, which is 128, then get the largest power of 2 that doesnt go over 5 (133-128=5), and then the largest power of 2 that matches or is equal to the largest power of 2 that doesn't go over 1 (5-4=1)
coal
so, the binary of 133 is 10000101