Anonymous
Hello
Anonymous
I'm new to this grp
ברני
Welcome, read the rules :)
Anonymous
Welcome, read the rules :)
U have too many rules
Luca
Guys is there some way to make not blocking input in C++? I'll try to explain you what I will like to do: user has 5 seconds to insert an input from keyboard, if he/she insert input in time, inserted value is printed on console, if times expire than program end.
Luca
the problem is that std::cin is blocking, so it stop execution flow
Anonymous
Can you declare any variable of size one bit in C?
Suka
Can you declare any variable of size one bit in C?
struck struck oneBit{ uint8_t bit:1; }; struck oneBit var01; var01.bit=1; cmiiw
Anonymous
1.3 State the name every syntax symbol in program 1. # : () : {} : “ : ; : Help me plis
Anonymous
I am taking a look at the SDL library a guy making a game
Anonymous
It’s in C++
Anonymous
I guess I’ll learn som c++ first
Kl44
int main (int argc, char *argc[]) { ithread_t cp_thread; if(0) { cp_thread=cp_thread; /*-Wextra, fix for unused parameters*/ } Hi, Can anyone help me to understand this code.. Facing an unused parameter issue at line ithread_t cp_thread, and didn't understand why that if condition is given, and also didn't understand the use of -Wextra comment
Alex
if (0) to not execute this instruction with this flag -Wextra compiler checks for unused parameter. usually in such case (void*) cp_thread is used or compiler attribute
Anonymous
Programming is LIFE. 😍😘
Makgato
Hello guys i need help
Name
Makgato it would be nice if you share your problem before others can help you solve it
Anonymous
Hey! Could anyone check an exercise for me please? I can't understand what's wrong in it
Anonymous
https://pastebin.com/H5aPX5sJ
Anonymous
It has to read data from a file with lines whose characters are just ' ' and '*'
Anonymous
I know there is an error in the lines of the file reading, but I can't get what error it is
Zannatul
Thanks for accepting me.
Engineer
Anyone playing with C++ on RISCV be it emulator or actual Hardware?
olli
Since this question is overly broad and lacks a lot of context: No, there might be systems where it does not work.
Dawood
Hi everyone! I need help to write a program to do a shopping list and there you can add remove and change the list! Can you help me?? Pls
olli
Make sure to target the correct architecture and redistribute the openssl library in case you rely on it (or link statically)
Anonymous
@admins
Anonymous
Hi I am amir✋
Anonymous
#include <stdio.h> void calc(float,float); void main (void){ float x, y, k; printf ("Type in 1st integer : \t"); scant ("%f", &x); printf ("Type in 2nd integer : \t"); scanf ("%f", &y); int k; k=calc(x,y); } printf ("After the calculation the k is %.3f\n",k); float calc(float x, float y) · { float m; m=(x+y)/3; return(m); } How to modify using function.someone help me
Anonymous
haii😁✋
Rajesh
Need help in command line argument programming
christian
So many mistakes and I had time 😂
#include <stdio.h> float calc(float x,float y); int main (void) { float x, y, k; printf ("Type in 1st integer : \t"); scanf ("%f", &x); printf ("Type in 2nd integer : \t"); scanf ("%f", &y); k; k=calc(x,y); printf("After the calculation the k is %.3f\n",k); } float calc(float x, float y) { float m; m=(x+y)/3; return(m); }
Gulshan
https://pastebin.com/H383B3SP
Gulshan
I am facing a time related issue in hackerearth... beside using that snippet provided by oli
Gulshan
I am also having an issue, when hackerearth puts larrge amount of input for this code.... The output seems to be incorrect
Gulshan
question: Monk loves to preform different operations on arrays, and so being the principal of Hackerearth School, he assigned a task to his new student Mishki. Mishki will be provided with an integer array A of size N and an integer K , where she needs to rotate the array in the right direction by K steps and then print the resultant array. As she is new to the school, please help her to complete the task. Input: The first line will consists of one integer T denoting the number of test cases. For each test case: 1) The first line consists of two integers N and K, N being the number of elements in the array and K denotes the number of steps of rotation. 2) The next line consists of N space separated integers , denoting the elements of the array A. Output: Print the required array.
Gulshan
My program worked fine with 1st input but hackerearth showing that 2 process took more time than expected... And 4 of the process gave the incorrect output
olli
I am facing a time related issue in hackerearth... beside using that snippet provided by oli
This problem does not seem to be IO bound so the small snippet should not have any impact on the outcome. Your algorithm is too slow. In general, inserting an element at the front of a vector is requires O(n) time, increasing the time complexity of your algorithm to O(n^2) - which is usually not suitable for n > 1000 (at least in coding challenges)
Gulshan
For this given question
olli
I have to learn that time complexity stuff... But can you please give me a hint that how can I reduce time
Do you actually need to copy all the elements into another vector? Can you do it by just "reading" from the input?
Gulshan
Do you actually need to copy all the elements into another vector? Can you do it by just "reading" from the input?
The question say that I have to shift the last element to the first k times, the best I can think is through vectors
olli
The question say that I have to shift the last element to the first k times, the best I can think is through vectors
yes, but it only asks you to print it (it doesn't care about the order in the vector)
olli
I don't know how to do that... A hint please 🥺
Given the vector, do you know which element is the first one you should print?
Gulshan
Given the vector, do you know which element is the first one you should print?
If the input is 1 2 3 4 5, and k=2 then I have to print 4 5 1 2 3...
olli
If the input is 1 2 3 4 5, and k=2 then I have to print 4 5 1 2 3...
yes - so you should be able to "compute" the start index. Starting from that index you can print A[(StartIndex + i) % n] to get the elements in the expected order. This does not require additional memory and runs in linear time, which is ideal for this problem.
Gulshan
I firstly thought to use array insead of vector, but the problem is that i have to swap all elements to their new location, eventually it will increase the time... Therefore I tried vectors...
Anonymous
Hey guys i want to buy a book on c++, is bjarnes good? I m at entry level, know untill pointers very good. I will begin studing someclasses as well.. Will it be any good or is too much as a book? Can you give me AN advice? I don t care about The price i just want to learn more.
Anonymous
Dima
/sban
ברני
int main (void) It's actually saying void main?
olli
int main (void) It's actually saying void main?
no, when declaring a function C does not require you to list all the parameters the function expects. One can use void to explicitly tell the function does not take any argument.
Roshan
Not to take returns?
Void in arguments states that there are no arguments.
Roshan
I guess there's no need to write it? Olli
olli
Not to take returns?
parameters are independent of return values. This only applies to C and not to C++. Let's look at this example extern void foo(); But what parameters does foo take? you call it with foo(2, 3); or foo("aa");. Using a C compiler this compiles just fine - however your program might crash at runtime. extern void foo(); int main() { foo(23, 45); foo("asdsad"); } ——————————————- If you use the explicit void extern void foo(void)` the only way to call the function is by not passing any paramters int main() { // this is fine foo(); // "too many arguments" // foo(23, 45); // "too many arguments" // foo("asdsad"); } —————————————— Hence, when writing C, you should prefer to write foo(void) when your function does not take any arguments. For C++ this is implicit.
Alex
If all my fields are private, does my code totally satisfy encapsulation OOP criteria? Are there any other requirements?
Roshan
If all my fields are private, does my code totally satisfy encapsulation OOP criteria? Are there any other requirements?
Yes I guess. But you won't be able to do anything with it as you cannot retrieve something through instantiation
Anonymous
Thankssss😍
Can i know name the type of function calc now?
Ranmuni Imesha Udayanga
Can you send the C++ source codes within .h, .cpp, .pro and .ui file formats extensions for the weather calender updating system?
Anonymous
Tkans for The answer. I will check The resource