Pradevel (Pratyush)
lol
Anonymous
16- Write a program to swap the first number with last number in an integer array elements A
Mahdi
Hi
Aslan Im
/get cbook
Roxifλsz 🇱🇹
/ban ad
Abbosjon
Hello , could someone please suggest me some resources to solve rectangle intersection problem , video or book or maybe some forum , thanks in advance
Anonymous
/get cbook
™barynium†⋆。˚🇧🇷
#include<iostream> using namespace std; int main() { int y,m; cout <<"please enter year"<<endl; cin>>y; cout <<"please enter month"<<endl; cin>>m; switch(m) { case 2:(y%4==0 && y&100 !=0 || y%400==0); cout <<"the month has 29 days"<<endl; break; case 4: case 6: case 9: case 11: cout <<"the month has 30 days"<<endl; break; case 1: case 5: case 3: case 7: case 8: case 12: cout <<"the month has 31 days "<<endl; break; default:cout<<"not valid"; } return 0; }
Merve
hi all, ı have a question. I want to use for example;
Merve
when press the button led is on, when pull the button led is off.
Merve
but ı want to use with pin interrupt this button
Naiko
hi guys, can someone help me? I created a makefile with the Visual Studio Code editor. The makefile is called "Makefile" and is a MAK file. The problem is that with the make command from the terminal it does not find any makefiles. Yet I am in the folder where it is saved ... What should I do ?
Merve
ı have some problems with high level and low level.
Merve
ı want to use rasing or fall egde
Merve
Anonymous
Talula
nuvoton n76e003
http://embedded-lab.com/blog/getting-started-nuvoton-8-bit-microcontrollers-coding-part-1/
Anonymous
#include <iostream> #include <chrono> #include <format> int main() { std::chrono::year_month y_m; std::cout << "Enter yyyy mm: "; std::chrono::from_stream(std::cin, "%Y %m", y_m); if (y_m.ok()) { std::cout << std::format("The month has {} days.\n", (y_m / std::chrono::last).day()); } else { std::cout << "Invalid month!\n"; } }
The idea is to help people with their code with maybe suggestions on how to improve it. Not to go off in a tangential direction and give them alternative code which may or may not even work on their compilers 🙂. Btw, most of the major organizations are yet to adapt C++17 itself. C++20 is a long way off especially for students because most schools still wont be using the latest compilers.
Anonymous
16- Write a program in c++ to swap the first number with last number in an integer array elements A
Anonymous
shilling C++20 once a day doesn't seem that bad
Anonymous
16- Write a program in c++ to swap the first number with last number in an integer array elements A
People gave you suggestions already. Show what you have done before asking for help.
Anonymous
ye but people often don't even know that these parts of C++ even exist. most schools would force Turbo C++ with no standard library other than iostream related facilities if they could.
The students dont have a choice. You can help them with their current code and point them to materials where they can learn about modern C++.
z
16- Write a program in c++ to swap the first number with last number in an integer array elements A
This is not a code writing service group, put away your homework! Do it yourself and show the specific part you don't understand, that would be fine.
Anonymous
set(Num 2) set(two 2) set(tree 3) string(REPLACE ${two} ${tree} res Num) message("result is ${${res}}") I want to replace text but cmake doesn't work am i do it right ?
Anonymous
You should be using ${Num}
nah I tried didn't work
Anonymous
you mean string(REPLACE ${two} ${tree} res ${Num}) right ?
Anonymous
didn't work showed me empty
Anonymous
you mean string(REPLACE ${two} ${tree} res ${Num}) right ?
got it i should change this line message("result is ${${res}}") to this message("result is ${res}")
Anonymous
tnx for help
•‿•
can anyone suggest me where to practice c programming questions ?
SR27
I didnt even notice that line. 😁
for( i=2; count<=num; i++ ) { int n = i; while (n % 2 == 0) n = n/2; while (n % 3 == 0) n = n/3; while (n % 5 == 0) n = n/5; if( n == 1 ) { count++; if(count == num) return i; } }
SR27
time complexity O(n) ?
Pavel
time complexity O(n) ?
Looks more like n log n
Anonymous
for( i=2; count<=num; i++ ) { int n = i; while (n % 2 == 0) n = n/2; while (n % 3 == 0) n = n/3; while (n % 5 == 0) n = n/5; if( n == 1 ) { count++; if(count == num) return i; } }
The time complexity is not directly proportional to num. It depends on how numbers that have only 2,3 and 5 as prime factors are distributed.
Ehsan
O(n) + O(log2 n) + O(log3 n) + O(log5 n) = O(n)
Surbhi
Can anyone explain this how , n^logn= O(2^n)
Anonymous
time complexity O(n) ?
I guess its O(n * 2^n) (not tight bound). And Ω(n lg n). Here n is num.
SR27
O(n)
sorry but it is not O(n)
Anonymous
It doesn’t matter; complexity is not associative.
Time complexity in this case is not dependent on the input. So something like n or n log n wont work here. The time complexity depends on the distribution. For ex running that algorithm for num = 100 in the range say 1 to 10000 would be a lot faster than running it in between say 2 consecutive zeroes of riemann zeta function say after the 1000th bernoulli number
SR27
O(n) * [ O(log2 n) + O(log3 n) + O(log5 n) ] = n log(n) in coding we treat log as log of base 2
SR27
?
Anonymous
But its not random distribution. This complexity requires some math to get it. But its not impossible. (I assume the input is 'num').
That is why I said it is not just a simple direct proportionality relation to any of the complexities that we regularly use like n, nlgn, n^2 and so on. It depends on the distribution of such numbers. And the math is not that complicated. I can show it here but unfortunately this is not the group for such discussions.
Anonymous
thanks
Anonymous
That is why I said it is not just a simple direct proportionality relation to any of the complexities that we regularly use like n, nlgn, n^2 and so on. It depends on the distribution of such numbers. And the math is not that complicated. I can show it here but unfortunately this is not the group for such discussions.
If the idea was to just find out the nth number that just has 2,3 and 5 as prime factors, then there are much better and simpler algorithms out there which are linear. The algorithm provided in the OP's question is not however efficient and determining its complexity is slightly tougher.
Anonymous
Can anyone explain this how , n^logn= O(2^n)
Let 2^x=n. n ^ log n = 2^(x*x) = O(2^(2^x)) = O(2^n)
Anonymous
hi guys, can someone help me? I created a makefile with the Visual Studio Code editor. The makefile is called "Makefile" and is a MAK file. The problem is that with the make command from the terminal it does not find any makefiles. Yet I am in the folder where it is saved ... What should I do ?
Run the command 'make' in the same directory where the makefile is located . It compiled the file in the same order mentioned in the makefile rule. It is usually stored in the source directory for your project.
Anonymous
plz send the efficient algorithm
https://hastebin.com/ehizerimuv.cpp Can be made much better with coroutines in C++23 (the one in C++20 is not full fledged yet) or even with ranges library in C++20. But the idea is the same as above.
Anonymous
O(n) * [ O(log2 n) + O(log3 n) + O(log5 n) ] = n log(n) in coding we treat log as log of base 2
you can prove it from the definition of big-<whatever> and the property that log(x to base a) = Alog(x to base b) where A is the constant log(b to base a)
Prince
Hello members,help me to develop a game for kids using c++
Lenin
hello. can anyone suggest me how i could improve my coding skills in c/cpp? i want to work on projects but i have zero experience. problem solving like hackerrack gets boring