C program
1
Name:
Anonymous
2010-07-13 18:06
Make me a C program that reads given two integers (no limits) and outputs the largest.
Do this in a proper GNU hello.c way .
2
Name:
VIPPER
2010-07-13 18:24
#!/usr/bin/perl
print my $a = <> < my $b = <> ? $a : $b;
print "JEWS " for(;;) or die "JEWS";
3
Name:
Anonymous
2010-07-13 18:48
>>2
That truly was
VIP quality.
4
Name:
Anonymous
2010-07-13 18:56
#include <stdio.h>
int main(void)
{ for(;;) putchar('9');
return 0; }
5
Name:
Anonymous
2010-07-13 19:10
#include <homework.h>//All possible assignements/problems
HOMEWORK_2301;
6
Name:
Anonymous
2010-07-13 19:12
#include <stdio.h>
void main(){
puts("The numbers are fully equal. Stop being racist!");
}
7
Name:
Anonymous
2010-07-13 19:24
>>5
[m] /hw/2010/2301.c:14: `};' warning: `
statement is empty or has no side effects
8
Name:
Anonymous
2010-07-13 19:24
/hw/2010/2301.c:14: `};' warning: `
statement is empty or has no side effects
9
Name:
Anonymous
2010-07-13 19:37
[code] int main()
{
printf("enter two numbers");
int a = scanf("%d");
int b = scanf("%d");
if (a > b)
printf(a);
if (a < b)
printf(b);
return;
}
10
Name:
Anonymous
2010-07-13 19:53
[/code]
11
Name:
Anonymous
2010-07-13 20:22
r = x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1)));
12
Name:
Anonymous
2010-07-13 20:27
>>1
two integers (no limits)
What does that mean? That we need to use unbounded integers?
13
Name:
Anonymous
2010-07-13 20:42
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char __=0,*_o=1[argv],*o_=2[argv];
strlen(_o)>strlen(o_)?--__:strlen(o_)>strlen(_o)?++__:__;
if (!__)
for (; *_o&&*_o==*o_ || (*_o?--__,*_o>*o_?__:--__:__)&&0;++_o,o_++);
return (printf)("%d\n",!__?~~0:++__?2:1) *0;
}
14
Name:
Anonymous
2010-07-13 20:49
>>13
usage: magic <uint_1> <uint_2>
output:
0 : uint_1 == uint_2
1 : uint_1 > uint_2
2 : uint_1 < uint_2
15
Name:
Anonymous
2010-07-13 22:57
1[argv]
This is valid? What does it do? What ends up being the value of *_o?
16
Name:
Anonymous
2010-07-14 0:09
>>15
Yes. It confuses people who don't know C. You can figure the last part out for yourself.
Also: don't you have a C compiler?
17
Name:
Anonymous
2010-07-14 1:37
>>15
You are a faggot, faggot. Haven't you read your K&R today?
18
Name:
FrozenVoid
2010-07-14 2:00
>>15
Arrays/Pointers in C can accessed by
array+index and index+array, which is just pointer_offset+pointer_base.
19
Name:
Anonymous
2010-07-14 2:36
>>18
That's just sick.
string("abc")+string("def") != string("def")+string("abc") even in c++. Probably we should fix this bug in C++-1x
20
Name:
Anonymous
2010-07-14 2:47
>>13
I'm an expect C programmer.
21
Name:
Anonymous
2010-07-14 2:48
string("abc")+string("def") != string("def")+string("abc")
what does string do there that it breaks the transitivity of addition?
22
Name:
Anonymous
2010-07-14 2:57
>>21
it doesn't break transitivity of addition.
this is about concatenation, which isn't transitive, ever.
23
Name:
Anonymous
2010-07-14 3:31
>>22
+ doesn't do concatenation. concatenation in c looks like
"abc" "def" and
"def" "abc".
24
Name:
FrozenVoid
2010-07-14 8:09
>+ doesn't do concatenation
Concatenation with + isn't normal, but in Sepples it is.
__________________
Orbis terrarum delenda est
25
Name:
Anonymous
2010-07-14 8:51
>>23
How did this become topical?
26
Name:
Anonymous
2010-07-14 8:56
>>25
The question is: what drugs K&R did, so pointer+integer became commutative? I want to know.
>>21,22
I don't think you know what transitive means, guys. But, well. Expect nothing less from /prog/
27
Name:
Anonymous
2010-07-14 9:34
>>23
Only with string constants.
28
Name:
Anonymous
2010-07-14 10:11
strcat
29
Name:
Anonymous
2010-07-14 10:16
>>24
Pretty sure it's
operator<<
30
Name:
Anonymous
2010-07-14 10:26
>>5
OP here... if this was an homework thread it would be done in Java.
31
Name:
Anonymous
2010-07-14 10:33
>>30
fuck java
also, how you like my solution?
>>13 that is
32
Name:
Anonymous
2010-07-14 13:05
@31: I wanted to tear my eyes out as soon as I saw char __=0,
33
Name:
Anonymous
2010-07-14 13:29
>>32
it's a perfectly cromulent variable name
34
Name:
Anonymous
2010-07-14 13:35
>>32, 33
yepp. identifiers in C are [_A-Za-z0-9]
35
Name:
Anonymous
2010-07-14 14:05
>>26
what drugs K&R did, so pointer+integer became commutative?
That's a fair question. What
I want to know is how the discussion of
strings became topical. They have nothing to do with this phenomenon.
To answer your question, the object is to support pointer arithmetic without requiring casts everywhere (try casting that...
blech! It's just as bad the other way around.) C is fairly hacky in a lot of places, but this isn't one of them. It just seems odd because it happens to work owing to the types involved.
36
Name:
Anonymous
2010-07-14 14:43
Addition is commutative. What were Russel and Whitehead smoking?!
37
Name:
Anonymous
2010-07-14 15:06
>>36
Blah, think about Niels Abel!
38
Name:
Anonymous
2010-07-15 3:23
#include <stdio.h>
int ab(char *a, char *b) {
while(*a!='\0'&&*a==*b&&*a++&&*b++); return *a-*b;
}
int main(int ac, char **a) {
int c = ac<3?0:ab(a[1], a[2]);
printf("%s\n",ac<3?"the fuck?!":c>0?a[1]:a[2]);
//printf("%s\n",ac<3?"fuck off":c>0?"1st greater":c<0?"2nd greater":"equal");
return 0;
}
39
Name:
Anonymous
2010-07-15 3:35
>38
>while(*a!='\0'&&*a==*b&&*a++&&*b++); return *a-*b;
while(*a!='\0'&&*b!='\0'&&*a==*b&&*a++&&*b++); return *a!='\0'&&*b!='\0'?*a-*b:*a=='\0'&&*b=='\0'?0:*a=='\0'?-1:1;
40
Name:
Anonymous
2010-07-15 4:07
int main(argc, argv) int argc; char** argv; { puts(argv[1]); return 0; }
It has a bug that I didn't fix: it works only in 50% of cases. But I think it's not that bad. Probably it's compiler failure.
Newer Posts