Anonymous
other than the most basic swap where you do bitwise operations (that too works on integral types only)
Anonymous
hints?
Anonymous
int top = stack.top(); ^^^ stack.pop(); // recur for the remaining elements in the stack sortedInsert(stack, key); // insert the popped element back in the stack stack.push(top); ^^^
Anonymous
the call stack?
Anonymous
:/
Anonymous
i guess
Caesy
please how can I make my stdin unbuffered
Caesy
I wish to read input immediately it's typed not until the enter button is pressed
Caesy
Am working on a text prediction project, so I need to access the characters as soon as they are typed
Hermann
Anonymous
hi guys. help me!!!!!
Anonymous
Anonymous
int (**arrayA)(int, int) = khoiTaoMT;
Anonymous
but i got some warnings
Anonymous
xxxx.c:16:32: warning: initialization of 'int (**)(int, int)' from incompatible pointer type 'int (*)(int, int)' [-Wincompatible-pointer-types] int (**arrayA)(int, int) = khoiTaoMT; ^~~~~~~~~ xxxx.c: In function 'khoiTaoMT': xxxx.c:63:12: warning: returning 'int (*)[(sizetype)(column)]' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion] return arrayA; ^~~~~~
Anonymous
please
Francisco
We clearly don't speak the same mother language, because I don't understand the name at all, and it's quite hard to figure out what the code does
Francisco
just simple code. i allocate memory for 2d array. and return. thats it
I would just rewrite the entire thing, because almost everything is bad. A simple function to allocate a matrix would be something like this: int** allocate_matrix(int rows, int cols) { int **rows_ = (int**)malloc(rows * sizeof(int*)); for (int i=0; i<rows; ++i) rows_[i] = (int*)malloc(cols * sizeof(int)); return rows_; }
Francisco
It returns a double pointer, but you can adapt it to work on a 1D array, but you then need to take care of the offsets yourself
noop
The way it is used, you need 1D array.
Francisco
And 100.000 3, and 100.0000 4, and 100.00000 5, ...
noop
I would suggest to define and release the allocated memories in the same place. Here you have defined and allocated memory and somewhere else you have to release it.
Anonymous
It returns a double pointer, but you can adapt it to work on a 1D array, but you then need to take care of the offsets yourself
https://stackoverflow.com/questions/40847172/best-way-to-allocate-memory-to-a-two-dimensional-array-in-c
Francisco
thanks. but i try follow like this. they siad it this way is better
The thing with 1D arrays is that you have better cache locality, but you shouldn't care about that unless you really need performance or you're willing to encapsulate that in a class or something like that
Noor
How to make default generated code by QtCreator to has left handside *, & on declarations.
Anonymous
Hi, can someone explain to me how to do this in C ++ "Calculate z = (x m1 + x m2) / 2, where x m1 and x m2 are the smallest elements of the arrays X 1 (N), X 2 (N). The process of determining the smallest element of an array is implemented as function. "
Anonymous
I can not understand the teacher’s explanation
Anonymous
Guys&
Anonymous
?*
01000001011011010100000101101110
I can not understand the teacher’s explanation
Can you explain exactly what you don't understand?
Caesy
Alright, will try it out
01000001011011010100000101101110
Well you can follow these steps to solve this problem. .Declare a function which takes arrays ( or vector ) . Read about getting smallest two elements online..there are many ways to do this..you can go with any approach . After finding the two elements return them as an array ( or vector) . Call the function in main and capture the array ( or vector) . Use the given formula and tbe value that you've recieved ( from the function that you've already implemented) And store the result of that formula in a different variable.
01000001011011010100000101101110
Oh...do I delete this?😅
Anonymous
Thanks
Anonymous
int (*)[column] and int ** are not the same things. pass around void *s and convert them to appropriate type as needed.
Anonymous
your single malloc is good
Francisco
this is actually the bad one. lookup tables are not how you should implement matrices in C
It's a "simple" function, I would use other techniques myself for matrixes, but I'm not going to spend more time than I need to
Anonymous
btw you can use arrayA[i][j] to access the elements
Francisco
🤷‍♂️ i would say the single malloc is "simpler"
Maybe, but using the final pointer outside the function without proper encapsulation is just shooting your own foot
Anonymous
Guys Hı
klimi
Anonymous
I have a problem about C
Anonymous
Can anyone solve is
Dima
Can anyone solve is
Read the rules
klimi
Can anyone solve is
people can but people wont solve it for you
Anonymous
Can you help me
Anonymous
KLİMİ
klimi
Can you help me
with what dear Sait
Anonymous
I have a problem about C
http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm see if someone already reported the problem
Anonymous
if not, write a defect report
Anonymous
My problem is basic but for me hard
klimi
It might be a personal problem.
you mean like character problem?
Anonymous
your task is to simulate the contagion process of an infectious disease. The environment will be provided as a 10x10 grid. Each cell of the grid will contain one of the characters 'H', 'I', and '-', where 'H' stands for a healthy, 'I' for an infected person. '-' means that this cell is not occupied by any person; in other words, it is empty. In each step of the simulation (for each generation), an infected person will infect all of his/her nearby healthy people. They can only infect through the directions of up, down, right, and left. Diagonal infection is not possible. The number of simulation steps is going to be provided as an input, and you will run the simulation accordingly. You will print the state of the grid after the last simulation step has completed. While you are computing the next generation,  you will consider only the state of the  PREVIOUS generation.
Anonymous
Problem like this
Anonymous
and i asked you what an approach would be
Anonymous
No
Anonymous
huh
klimi
ey you posted this before
either him or someone else huh...
Anonymous
Anonymous
I tried to solve but ı cant anything
Dima
try
Dima
we won’t write a code for you
Anonymous
Why
Anonymous
I really need help
Dima
read the rules
Dima
just try to write something
Anonymous
Can you say
klimi
I really need help
sure we can help if you have some c/c++ doubt
Anonymous
The problem easy or hard
klimi
The problem easy or hard
what is your doubt?