PO
Alex
check all pointers for NULL
Alex
also I don`t know about comment function
Alex
and this one
int array = sizeof(line);
fseek(opf, -array, SEEK_CUR);
is weird
PO
also I don`t know about comment function
My program open a pnm file which contain a matrix
it scann the matrix
but before scanning the matrix there is a comment line which begin with #, remove comment detect that and comment() remove it
Youssef
25
How you solve it because i got another answer
Anonymous
Nils
@PO_uria by the way... Why not just get the file format that the user wants from the filename?
Anonymous
Here's the question:
codechef(dot)com/problems/HORSES
And here's my code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, t, n,res;
scanf("%d",&t);
for(i = 0; i < t; i++){
scanf("%d",&n);
res = diff(n);
printf("%d\n",res);
}
return 0;
}
int diff(int num){
int arr[num];
int i, min = 1000000001, j, k;
for(i = 0; i < num; i++){
scanf("%d",&arr[i]);
}
for(i = 0; i < num; i++){
for(j = 0; j < num; j++){
k = abs(arr[j] - arr[i]);
if(k < min && k != 0)
min = k;
}
}
return min;
}
I'm getting the correct outputs when I run with custom inputs. Can someone tell me where I'm wrong? I know this is an easy question and most of you here are pros, but any help is appreciated. Thank you.
Martin
@shshshhsll Just guessing. But it seems you are avoiding comparing the same horse by testing if k!=0 (since the same horse gives the same value)
Martin
But it is possible for k to be 0 in other conditions (ex: different horses have the same value)
Anonymous
Anonymous
Anonymous
#include <stdio.h>
int main()
{
int x = 45;
if( x > 95)
{
printf( "Student is brilliant\n");
}
if( x < 30)
{
printf( "Student is poor\n");
}
if( x < 95 && x > 30 )
{
printf( "Student is average\n");
}
}
Pavel
Anonymous
Anunay
Not warning you for the sticker this time.. but don't post such stuff
Sky
Sky
thank you sir.
Anunay
You can share normal stickers
Anunay
That one was kinda nsfw
Dima
Lol
Sky
Sky
Is this ok?
Artöm
Sky
Anunay
CappedCrusader
CappedCrusader
How to call the print() function of the class A from the object of class D in this Hybrid inheritance
CappedCrusader
How to call the print() function of the class A from the object of class D in this Hybrid inheritance anybody please
Artöm
d.A::print()
Artöm
Oh it would be ambiguous I assume
CappedCrusader
Yes
Artöm
One can do static_cast<B&>(d).A::print()
Artöm
It is a cast to subobject b of object d. b has unambiguous (one) base A
CappedCrusader
Anonymous
Is it necessary to have deep knowledge of os for being a protocol developer?
Anonymous
Hi
klimi
Anonymous
🤪
I_Interface
.
klimi
Hi?
Hey sergey, long time no see! still developing?
I_Interface
Anonymous
N4gu4l
Hi there !
Anonymous
@GitGpAdmin
Anonymous
Admin
Anonymous
Need data structures pdf latest version
Nils
Hi, is there any number type that somehow, magically, can hold as big numbers as the memory allows?
Nils
piyush
/get
Mohammed Athar
Hi
Mohammed Athar
I Am New friends
Dima
Hey New
I_Interface
Mohammed Athar
Yes
Indolent
Can anyone explain to me what is happening in this code?
Indolent
https://pastebin.com/9A0QN48L
Indolent
Most importantly how can we pass it as "vec2" on line 10? It should be something like &vec2 right? How is it still working?
Anonymous
Hello.
size_t func(size_t num) {
return num;
}
int main() {
size_t k = 2;
size_t n = func(k);
std::cout « n « std::endl;
}
Anonymous
Why n print to me like 0?
Anonymous
https://pastebin.com/3Y4sFFGy
When enter to if (current_sum == sol_number) and sol_size is different to 0 in ligne 6 print ZERO
Anonymous
Can anyone help me to figure out what is wrong with the code?
Anonymous
After compiling, I get Salary as 0.
Anonymous
I kept on staring and I just realized it was all my arrangement of the inputs. Fixed it. Thanks.
Patrick
Hello, how can I ensure a copy constructor copies into a blank object rather than an already instantiated one? It is causing a really nasty bug for me previously gone unnoticed
Naman
Patrick
I know what object it's pointing to, and it's not blank
Patrick
In the error, *this is a pointer inside my &obj, which is causing a recursive issue
Patrick
generally I watch the copy constructor copy into a blank *this
Naman
Are you passing the object by reference inside copy constructor?
Patrick
and for the first hit in a particular function it is blank... but the second time it's not
Naman