Lenin
oo thanks for your input
Anonymous
oo thanks for your input
https://github.com/fffaraz/awesome-cpp
Here are some C++ repositories. Pick 1 that you like. But be aware that these repositories are starred heavily and hence there will be multiple committers. Unless the change you offer is very enticing, it is highly likely that your code will be rejected. Dont let that disappoint you.
Lenin
𝙰𝚖𝚖𝚊𝚛
Hello everyone, could anyone tell me what is the best source to learn Dynamic programming (DP)
Anonymous
𝙰𝚖𝚖𝚊𝚛
Anonymous
Thank you, is it for beginners?
Dynamic programming doesnt require you to know other techniques like Greedy and Divide and Conquer. It wont hurt if you know them but. You must know how to calculate complexity of algorithms but.
𝙰𝚖𝚖𝚊𝚛
Anonymous
𝙰𝚖𝚖𝚊𝚛
Not really.
Ok thanks, is there any free books about it ?
Anonymous
Anonymous
I see, but don't it need a special requirements?
Dynamic programming is an approach, resting in logical thinking. You form the recurrence, and use memoization, that's top down approach. You use an iterative method using 2D (if there are 2 states that are getting changed) and so on, that's bottom up approach.
Anonymous
23.Write program in c++ find the position of min and max element in one
dimension array
Anonymous
https://github.com/mgood7123/prebuilder
Anonymous
Anonymous
•‿•
can someone suggest me where to practice c programming questions as a beginner ?
Hanz
•‿•
Hanz
np
Anonymous
"The strategy behind the usual arithmetic conversions is to convert operands to
the “narrowest” type that will safely accommodate both values. (Roughly speaking,
one type is narrower than another if it requires fewer bytes to store)"
"Among the most common promotions are the integral promotions, which convert a character or short integer to type int"
These two lines are from a book I'm reading. How can those two go together, given that char or short always occupy less memory than int?
Shourya
Anonymous
Anonymous
.Write program in c++ find the position of min and max element in one
dimension array.
Ravi
iterate over the array, and track the current minimum and maximum element at each point. Thats the logic, write the program by yourself it is not hard if you try.
drinktoomuch
Pradevel (Pratyush)
Tute
/get cppbookguide
Surbhi
Anonymous
https://dpaste.org/8ZGw
NOT SHOWING ANY ERROR BUT IN VOID PLAY SECTION AFTER I PRESS ANY KEY THEN ENTER THE PROGRAM STOPS
Ravi
Ravi
in show function second last line
Ravi
thirdt last*
Anonymous
#include<stdio.h>
#include<stdlib.h>
int main()
{
int apple=50,banana =60, mixture=0;
printf("Number of apples in the bucket: %d\n",apple);
apple--;
printf ("Number of fresh apples remaining after one rotten apple threwn out: %d\n",apple);
printf("Number of bananas in the bucket: %d\n",banana);
++banana;
printf("Number of bananas in the bucket after adding one into it: %d\n",banana);
mixture=apple+banana;
printf("total number of apple and banana: %d\n",mixture);
apple=12;
banana=15;
mixture=(apple++)*(++banana);
printf("turnover is the product of banana and apple: %d\n",mixture);
mixture = (float)banana/(float)apple;
printf("loss is the quotient of apple and banana: %f\n",mixture);
float loss;
loss=(float)banana/(float)apple;
printf("loss is the quotient of apple and banana: %f\n",loss);
return 0;
}
Anonymous
In the above case, why quotient value is not getting updated into the mixture variable ?
But if I replace the 'mixture' into some other variable like in the above case I had written 'loss' then the exact function will work.
Anonymous
Anonymous
Thomas shelby
1st
#include<stdio.h>
void printTwoOdd(int arr[], int size)
{
  int xor2 = arr[0];
  int set_bit_no; 
  int i;
  int x = 0, y = 0;
  for(i = 1; i < size; i++)
    xor2 = xor2 ^ arr[i];
  set_bit_no = xor2 & ~(xor2-1);
  for(i = 0; i < size; i++)
  {
     /* XOR of first set is finally going to hold one odd
       occurring number x */
    if(arr[i] & set_bit_no)
      x = x ^ arr[i];
    else
      y = y ^ arr[i];
  }
 
  printf("\n The two ODD elements are %d & %d ", x, y);
}
int main()
{
  int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};
  int arr_size = sizeof(arr)/sizeof(arr[0]);
  printTwoOdd(arr, arr_size);
  getchar();
  return 0;
}
2nd
#include<stdio.h>
void print2odd(int arr[], int size)
{
int xor2 = arr[0], set, i, x = 0, y = 0;
for(i = 0; i < size; i++)
xor2 = xor2 ^ arr[i];
set = xor2 &~(xor2 - 1 );
for(i = 0; i < size; i++)
{
if(arr[i] & set)
x = x ^ arr[i];
else
y = y ^ arr[i];
}
printf("%d & %d", x, y);
}
int main()
{
int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};
int arrsize = sizeof(arr) / sizeof(arr[0]);
print2odd(arr, arrsize);
getchar();
return 0;
}
Thomas shelby
1st
#include<stdio.h>
void printTwoOdd(int arr[], int size)
{
  int xor2 = arr[0];
  int set_bit_no; 
  int i;
  int x = 0, y = 0;
  for(i = 1; i < size; i++)
    xor2 = xor2 ^ arr[i];
  set_bit_no = xor2 & ~(xor2-1);
  for(i = 0; i < size; i++)
  {
     /* XOR of first set is finally going to hold one odd
       occurring number x */
    if(arr[i] & set_bit_no)
      x = x ^ arr[i];
    else
      y = y ^ arr[i];
  }
 
  printf("\n The two ODD elements are %d & %d ", x, y);
}
int main()
{
  int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};
  int arr_size = sizeof(arr)/sizeof(arr[0]);
  printTwoOdd(arr, arr_size);
  getchar();
  return 0;
}
2nd
#include<stdio.h>
void print2odd(int arr[], int size)
{
int xor2 = arr[0], set, i, x = 0, y = 0;
for(i = 0; i < size; i++)
xor2 = xor2 ^ arr[i];
set = xor2 &~(xor2 - 1 );
for(i = 0; i < size; i++)
{
if(arr[i] & set)
x = x ^ arr[i];
else
y = y ^ arr[i];
}
printf("%d & %d", x, y);
}
int main()
{
int arr[] = {4, 2, 4, 5, 2, 3, 3, 1};
int arrsize = sizeof(arr) / sizeof(arr[0]);
print2odd(arr, arrsize);
getchar();
return 0;
}
Can anyone tell the difference between these 2 codes
Am getting different outputs
Thomas shelby
Anonymous
Ok. Outside of that I cant tell what's the difference between the two codes, they are basically the same except for that
hossein sharifi
Hi
hossein sharifi
Pleas help me
Anonymous
I Waaaana find the odd occurance of 2 numbers in a arry
Yup. The second code is wrong. The initial value of i should be 1.
By the way, you can use set_bit_no=xor2&(-xor2) instead of set_bit_no=xor2&~(xor2-1). They have same effect, but the former is better.
hossein sharifi
Write a program that takes the elements of an array from the input, calculates the factorial of each of them, and finds and prints the largest number of calculated values. (Specify the number of array elements by the user.
hossein sharifi
Ravi
Thomas shelby
Anonymous
Is opencv the best way to work with a webcam on Windows using C?
Thomas shelby
Opencv and pythons would be better
Thomas shelby
Anonymous
Opencv and pythons would be better
I understand. I thought about making a C program which recognize a face and put an image on, like a mask. A simple image, when you move your face the image follows you
Anonymous
No fancy effects
Thomas shelby
Okay
Pradevel (Pratyush)
@𝑺𝒐𝒃𝒌𝒂
@𝑺𝒐𝒃𝒌𝒂
#ide
Anonymous
Anonymous
C++ is better if you are serious I get it
Shourya
Are system V semaphores still used ? One of my seniors today raised a MR and I commented not to use them as they are heavy and not POSIX complaint ?Had a heated argument...Anyways ...Anyone has more to add why not to use them?
Anonymous
What are some ways to check execution time of my C++ program? I mainly need it for Competitive Programming purpose - I tried some online solutions, and each time I run it, it gives a different result (of execution time) :/
Anonymous
Anonymous
https://github.com/sharkdp/hyperfine
I don't want a terminal based one, because I usually create a Sublime snippet and I wanna put a piece of code to get it while running it
Apk
Apk
Anonymous
auto start = chrono::high_resolution_clock::now();
//----------
solve();
//-------------
auto end = chrono::high_resolution_clock::now();
double time_taken = chrono::duration_cast<chrono::nanoseconds>(end - start).count();
time_taken *= 1e-9;
cout << "Time: " << fixed << time_taken << setprecision(9); cout << " sec" << endl;
I was using this
Apk
Anonymous
Anonymous
Altho it's not compulsory, I was experimenting