Anonymous
It shows 11
Anonymous
I am unable to understand
Anonymous
/report screen picture and asking for solution
Anonymous
/report
Anonymous
Sorry I forgot the rules
Anonymous
I was having my exam today at 1:30 so in a hurry I
Anonymous
Put this
Anonymous
int n; cin >> n; int cnto = 0; for (int i = 0; i < n; ++i) { int x; cin >> x; cnto += x & 1; }
Anonymous
wt work is the & doinng here in 7th line
olli
wt work is the & doinng here in 7th line
bitwise and operators https://en.wikipedia.org/wiki/Bitwise_operation#AND
Anonymous
thank u
rex
int n; cin >> n; int cnto = 0; for (int i = 0; i < n; ++i) { int x; cin >> x; cnto += x & 1; }
https://www.google.com/amp/s/www.geeksforgeeks.org/bitwise-operators-in-c-cpp/amp/
Dima
Alexander
Hello C++ newbie here. What's the best way to achieve this with smart pointers? struct Foo { vector<int> numbers; int* cur_number; }; int main() { Foo foo; foo.numbers.push_back(1); cout << foo.numbers[0] << endl; // 1 foo.cur_number = &foo.numbers[0]; *foo.cur_number = 2; cout << foo.numbers[0] << endl; // 2 } I want the cur_number field point to any value in the vector and to modify the original vector by modifying cur_number. I tried unique_ptr, but the value was copied, and I could not modify the original array. Perhaps shared_ptr? Thanks
Anonymous
Smart pointers are used to OWN an object
Anonymous
You don't need to own an object, you just point to the object
Anonymous
#include <bits/stdc++.h> using namespace std; #define jeno_joyer_khuda_thake int main (void) #define kaj_shesh return 0 #define sf scanf #define pf printf #define ssf sscanf #define spf sprintf #define fsf fscanf #define fpf fprintf #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define scase sf ("%d",&tc) #define whilecase while (tc--) #define sn sf ("%d",&n) #define eof while (cin >> n) #define pcase pf ("Case %d: ",pos) #define llu unsigned long long #define lld long long #define U unsigned int #define for0(i,n) for (i=0; i<n; i++) #define for1(i,n) for (i=1; i<=n; i++) #define forab(i,a,b) for (i=a; i<=b; i++) #define rof0(i,n) for (i=n-1; i>=0; i--) #define rof1(i,n) for (i=n; i>=1; i--) #define rofab(i,a,b) for (i=b; i>=a; i--) #define c(str) cin >> str #define g(str) getline (cin,str) #define vi vector <int> #define vlld vector <lld> #define si set <int> #define slld set <lld> #define ss set <string> #define vs vector <string> #define pii pair <int,int> #define mii map <int,int> #define msi map <string,int> #define pb push_back #define in insert #define B begin() #define E end() #define rB rbegin() #define rE rend() #define F first #define S second #define iterate(it,x) for (it=x.B; it!=x.E; it++) #define sortR(x,a,b) sort (x.B+a,x.B+b+1) #define rev(x) reverse (x.B,x.E) #define revR(x,a,b) reverse (x.B+a,x.B+b+1) #define cl(x) x.clear() #define end1 "\n" const int MOD = 1000000007; const int MAX = 1000001; const double PI = acos(-1.0); int SetBit (int n, int X) { return n | (1 << X); } int ClearBit (int n, int X) { return n & ~(1 << X); } int ToggleBit (int n, int X) { return n ^ (1 << X); } bool CheckBit (int n, int X) { return (bool)(n & (1 << X)); } int arr[105]; jeno_joyer_khuda_thake { /*** freopen ("input.txt","r",stdin); freopen ("output.txt","w",stdout); ***/ int n,i,j,ans,mini; while (sf ("%d",&n) != EOF) { for (i=0; i<n; i++) sf ("%d",&arr[i]); ans = 1e9+7; for (i=0; i<n; i++) { mini = 0; for (j=0; j<n; j++) if (abs(arr[i]-arr[j]) & 1) ++mini; ans = min (ans,mini); } pf ("%d\n",ans); }
Anonymous
kaj_shesh; } 1. why so much define? 2.why these function int SetBit (int n, int X) { return n | (1 << X); } int ClearBit (int n, int X) { return n & ~(1 << X); } int ToggleBit (int n, int X) { return n ^ (1 << X); } bool CheckBit (int n, int X) { return (bool)(n & (1 << X)); } 3. why first ans is declared 1e9+7
Anonymous
this is the problem
Vitor
this is the problem
As far as I understood the cost will be min(number of odds positions, number of even positions)
Vitor
If you pay one coin you move any odd/even to an even/odd position, after that moving 2 is free so you don't spend any more coins
Anonymous
what abt the functions...we dont need'em in this code
Anonymous
Anonymous
/get findprojects
S
/get
Subhahu
Full cracked software (150+)
Dima
/ban Full cracked ban
professor
hey guys why this acts as a if not if (strlen(msg) % 8) instead of if (!strlen(msg) % 8)
Talula
hey guys why this acts as a if not if (strlen(msg) % 8) instead of if (!strlen(msg) % 8)
Remainder or mod is NOT a True or False answer... it could be any number below 8.
Talula
hey guys why this acts as a if not if (strlen(msg) % 8) instead of if (!strlen(msg) % 8)
If you're trying to check if the number is divisable by 8, use if ((strlen(msg) % 8 ) == 0)
Anonymous
warning = ub
Does that always mean that? Just asking.
Nasar Ul zain azran
Can anyone help me out to find c logical skill developing app or telegram group
Samsung
hello
Samsung
nice too join with this group
Harish
Can someone help me to WAP to find the size of variables using macro without using datatypes and sizeof operator in C programming
Kharon
maybe another one break in outside loop
Anonymous
This code... is unreadable
Ибраги́м
Use PasteBin
Chetan
/get noendl
Dima
Such a suspicious name
Pete
How do I get how fast a program takes to run?
Pete
I’m in visual studio
Pete
Write better code
You’ve just wasted both of our time with that reply
Anonymous
Learn how to make efficient programs
Pete
Dude, this is the answer :)
I have two programs, one will be faster than the other. I wanted to see the time of both and compare the two.
Anonymous
What you want is called benchmarking
Anonymous
And it is a hard topic really
Anonymous
https://youtu.be/YG4jexlSAjc i think this is enough for you
Pete
Anonymous
Thank you
Francisco
Javi
How do I get how fast a program takes to run?
The simplest way is using the chron library and wrappring your code between two calls to the system clock
Javi
You can also use valgrind to know the time spent ineach part of the program
Francisco
You can also use valgrind to know the time spent ineach part of the program
Valgrind isn't a tool for benchmarking but for finding leaks in your code
Jaydeep
I want learn about polymorphism can anybody send a video or blog or any thing I tried to lookout on the internet but I couldn't understand much
Anonymous
/report offtop
Anonymous
/report offtop
wts the problem
Anonymous
I_Interface
wts the problem
No one won't to do your homework here.
Anonymous
im not doing homework.i just asked help.
I_Interface
im not doing homework.i just asked help.
Check your algorithm then. Step by step.
Anonymous
im not doing homework.i just asked help.
Competitive programming is offtop here Can you understand this?
Anonymous
Only if you understand why the language behaves in an unexpected way is not an offtop
Vivek