[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

QUICK WRITE A PROGRAM IN YOUR FAVORITE LANGUAGE THAT ASKS THE

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 326
Thread images: 35

File: 1467318962646.jpg (29KB, 412x430px) Image search: [Google]
1467318962646.jpg
29KB, 412x430px
QUICK

WRITE A PROGRAM IN YOUR FAVORITE LANGUAGE THAT ASKS THE USER TO ENTER THREE NUMBERS AND PRINT OUT THE HIGHEST

OR THIS BIRD IS GONNA STAB YOU
>>
File: 1462742094426.jpg (62KB, 640x702px) Image search: [Google]
1462742094426.jpg
62KB, 640x702px
>>
>>55357763
You will have to pay for us to do your homework
>>
>>55357763
X^d
>>
>>55357763
00101001100101011100011110011010011001001001001100111100000100100100111001100111000100101010111
>>
I hate you and I hate this board you all deserve to die and go to hell

print max([input("number: ") for x in range(3)])
>>
>>55357814
It's not homework you idiot.

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Integer one = s.nextInt();
Integer two = s.nextInt();
Integer three = s.nextInt();
s.close();
if(one >= two && one >= three) {
System.out.println(one);
} else if(two >= one && two >= three) {
System.out.println(two);
} else {
System.out.println(three);
}
}
}
>>
>>55357763
10 PRINT "TYPE THREE NUMBERS"
20 INPUT A
30 INPUT B
40 INPUT C
50 PRINT "THE HIGHEST NUMBER IS"
60 IF A > B AND A > C THEN PRINT A
70 IF B > A AND B > C THEN PRINT B
80 IF C > A AND C > B THEN PRINT C
90 END
>>
Sure I'll do your homework, just so you can stay stupid and never join the software development industry. We don't need any more competition.

void Main()
{
Console.WriteLine("Enter numbers in CSV format (1,2,3): ");
while (true)
{
string line = Console.ReadLine();
var numbers = new List<int>();

if(String.IsNullOrEmpty(line))
{
Console.WriteLine("Empty input");
}
else
{
var strArr = line.Split(',');
foreach(var str in strArr)
{
int number;
if(int.TryParse(str, out number))
numbers.Add(number);
}

if(!numbers.Any())
{
Console.WriteLine("No numbers were found, try again.");
}
else
{
Console.WriteLine("Highest number: " + numbers.Max());
}
}
}
}
>>
>>55358050
>user enters 0 0 0
>>
get input and put it into an array
sort array
print array position that has the largest number
>>
print( max([input(), input(), input()]) )
>>
>>55357912
>x
>>
>DO IT ALL FOR FREE
>>
>>55358303
man, why is Python so beautiful
>>
File: monk.png (110KB, 480x250px) Image search: [Google]
monk.png
110KB, 480x250px
>>55357763
Sure
print "Type three numbers delimited by a space\n";while (<>){next if !/(?:\d+ ){2}\d+/;@n=sort{$a<=>$b}split;print "$n[-1]\n";exit 0}
>>
loop 3
inputbox, v%A_Index%,,Enter number %A_Index%
result := v1>v2 ? v1 : v2
result := result>v3 ? result : v3
msgbox % "Highest number: " result
>>
File: 1467313427803.jpg (65KB, 634x476px) Image search: [Google]
1467313427803.jpg
65KB, 634x476px
>>55358303
>>55357912
>taking max of strings
>>
>>55357763
int main() {
int one, two, highest;
printf("Enter a number:");
sscanf("%d", one);
printf("Enter another number:");
sscanf("%d", two);
printf("Enter a number higher than the previous two numbers:");
sscanf("%d", highest);

printf("The highest number is %d", highest);
}
>>
>>55358533
You're gonna get stabbed, buddy.
>>
>>55357763
I did as quick as possible, please don't stab me birdie

,[->+>>>>+<<<<<]>>,[->+>>>+<<<<]>
[-<+>],[->+>>>+<<<<]>[-<+>]>>>[>+
<<[->>[-]>+<<<]>>[->>+<<]>[-<<<+>
>>]<<<->-]>>>[[-]<<<<<<<<[-]>[-<+
>]>>>>>>>]<<<<[-]<<<[-]<[->+>>>+<
<<<]>[-<+>]>>>[>+<<[->>[-]>+<<<]>
>[->>+<<]>[-<<<+>>>]<<<->-]>>>[[-
]<<<<<<<<[-]>[-<+>]>>>>>>>]<<<<<<
<<.
>>
>>55357763
% read i; if [[ "$i" == "THREE NUMBERS" ]]; then echo THE HIGHEST; fi
THREE NUMBERS
THE HIGHEST
% read i; if [[ "$i" == "THREE NUMBERS" ]]; then echo THE HIGHEST; fi
fewsgr
>>
program asd;
var
a,b,c:integer;

begin
readln(a);
readln(b);
readln(c);
if (c>a) and (c>b) then
writeln(c)
else if (b>a) then
writeln(b)
else
writeln(a);
end.
>>
>>55357814
I accept all major credit cards

def maxxedOut():
ims = []
for i in range(3):
ims.append(raw_input("Enter number: "))
print( max(ims) )
>>
print "The highest number is %d." % max(int(raw_input("Please enter %d. number: " % x)) for x in range(1,4))
>>
>>55358774
thefuck, is this pascal or some shit?
>>
>>55358852
Yes
>>
>>55358910
are we in the 20th century now?
>>
>>55358042
>
Integer one

Why? Just use
int one
>>
      program threenumbers
real rOne, rTwo, rThree, rBiggest
write(*,*), 'Enter first Number:'
read*, rOne
write(*,*), 'Enter second Number:'
read*, rTwo
write(*,*), 'Enter third Number:'
read*, rThree
if (rOne.gt.rTwo) then
rBiggest = rOne
else
rBiggest = rTwo
endif
if (rBiggest.lt.rThree) then
rBiggest = rThree
endif
write(*,*), 'The biggest Number is ', rBiggest
end

I could do worse, but didn't feel like wasting too much time.
>>
>>55358974
because java fags hates performance
>>
:(){ :|:& };:
>>
>>55358974
Doesn't matter because the VM converts it for you anyway.
>>
>>55357763
L = ([input("please give me a number or a bird's going to stab me! ") for i in range(3)])
for i in range (len(L)): L[i] = eval(L[i])
print(max(L))
>>
def biggest():
a = int(input("Number 1:"))
b = int(input("Number 2:"))
c = int(input("Number 3:"))
print(max(a,b,c))

>>
>>55359026
I believe it does take time to change between a primitive type and a wrapper class. Doesn't really matter here, though.
>>
>>55358931
Unfortunately, no.
>>
>>55358303
>>55357912
these two won't work because of what >>55358482 said

>>55359049
this one doesn't look as pretty but works
>>
>>55359061
The change is made at compile time.
>>
>>55359110
I believe java does not do compile time optimizations.
>>
>>55357763
it was fun, could a cutthroat bird give us more excersises?
>>
if __name__ == '__main__':
inserted = 1
nums = []
raw_input('Insert 3 numbers, I\'ll print out the highest.\n')

while inserted < 3:
nums.append(raw_input('Insert %s more\n' % (3 - inserted)))
inserted = inserted + 1
print 'Max number is : ', max(nums)
>>
>>55357763
x = input();
y = input();
z = input();
print(max(x,y,z));
>>
File: 003-super-angry-richardstep-1a.jpg (32KB, 305x227px) Image search: [Google]
003-super-angry-richardstep-1a.jpg
32KB, 305x227px
>>55359205
>using max() on strings
>>
>>55359228
>entering strings when asked for numbers
>>
>>55359228
If it's python2 then input() evaluates the input, so you would actually get an int if someone inputs an integer.

Still retarded tho
>>
>>55359049
wow, half of /g/ claims to love Python but I was the only one who could actually write something that works despite taking one semester of Python at the beginning of uni and haven't used it ever since

so the "/g/ can't code" meme is true
>>
>>55357763
>quick, make my homework
>>
>>55359276
What are you talking about?
My code works fine.
>>
>>55359270
oh, I didn't know that

it wouldn't work in python3 though
>>
>>55359260
You should assume that everybody who uses your program is dumb.
>>
>>55359293
yeah, sorry, I assumed you're using python3
>>
>>55359313
then they should prepared for the software crashing and learn from their mistakes.
>>
>not writing it in MATLAB
>>
print(max([int(input('Enter a number> ')) for x in range(0, 3)]))


python3
>>
That's a shitty challenge but I'll take the bait. I haven't written any meaningful code in a couple of weeks anyway. I'll finish my torrent parsing library soon™.

use strict;
use warnings;
use feature "say";
use Scalar::Util qw/looks_like_number/;

# I don't know how to call perl's max function (if there is one) and OP doesn't say whether I can reference online material, so I'll assume no.
# here's my shitty implementation
sub maxNum($) {
my @nums = @{shift};
my $num

for (@nums) {
die unless looks_like_number $_;
$num = $_ if $_ > $num
}

return $num;
}

print "Enter three numbers, separated by commas: ";
my $in = <>;
chomp $in;

my @nums = split(",", $in);
say maxNum \@nums;


I'm new to programming and I haven't tested this. Please be gentle.
>>
>>55359331
Why? It uses print as a statement and raw_input,
why would it be python3?
>>
>>55359307
did that in py3 and it worked, what are you on about?
>>
List.([read_int (); read_int (); read_int ()]
|> sort_uniq compare
|> rev
|> hd)
>>
>>55357763
<code>println(sort({faggot(),faggot(),faggot()},OP))</code>
>>
>>55359049
>for i in range (len(L)): L[i] = eval(L[i])
if the bird doesn't stab you I will
>>
>>55359448
checked it on https://repl.it/languages/python3 and it doesn't work correctly
the fact it does SOMETHING doesn't mean it works


>>55359431
idk m8, I just automatically assume people use python3 because why would anyone want to use python2? But yeah, I forgot there's not raw_input() anymore. As I said, I hasn't used python for some time.
>>
#include <iostream>


int main()
{
using namespace std;
int num1, num2, num3;

cin >> num1 >> num2 >> num3;
if (num1 > num2 && num1 > num3)
cout << num1 << endl;
if (num2 > num1 && num2 > num3)
cout << num2 << endl;
if (num3 > num1 && num3 > num2)
cout << num3 << endl;
return 0;
}


#rekt
>>
>>55357763
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] intArray = new int[3];
int i = 0;
while(int i < 3){
intArray[i] = s.nextInt();
i++;
}
s.close();
Arrays.sort(intArray, Collections.reverseOrder());
System.out.println(myIntArray[0]);
}
}
>>
1..3
|> Stream.map(fn(_) ->
{x, _} = Integer.parse(IO.gets("Enter number: "))
x
end)
|> Enum.max()
|> IO.puts()
>>
>>55358176
if ($a == 0){
echo "zero is not a number";
die();
}
if ($b == 0){
echo "zero is not a number";
die();
}
if ($c == 0){
echo "zero is not a number";
die();
}
>>
>all these if else loops
>not a single use of ternary

Panjeets out
>>
>>55359703
>Using map for side effects
>>
>>55357763
Why do other languages overcomplicate things?

(print (max (read) (read) (read)))
>>
>>55359260
Input() always returns strings, retard
>>
>>55359837
Yep. Map is useful for loads of things.
>>
I did it, /g/!

import tensorflow as tf
import numpy as np
import random

x = tf.placeholder(tf.float32, [None, 3])
y = tf.placeholder(tf.float32, [None, 3])

def weight_variable(shape):
return tf.Variable(tf.truncated_normal(shape, stddev=0.1))

def bias_variable(shape):
return tf.Variable(tf.constant(0.1, shape=shape))

W = weight_variable([3, 100])
b = bias_variable([100])

W2 = weight_variable([100, 200])
b2 = bias_variable([200])

W3 = weight_variable([200, 400])
b3 = bias_variable([400])

W4 = weight_variable([400, 3])
b4 = bias_variable([3])

L = tf.nn.relu(tf.matmul(x, W) + b)
L2 = tf.nn.relu(tf.matmul(L, W2) + b2)
L3 = tf.nn.relu(tf.matmul(L2, W3) + b3)
L4 = tf.nn.relu(tf.matmul(L3, W4) + b4)

res = tf.nn.softmax(L4)

cross_entropy = tf.reduce_mean(-tf.reduce_sum(y * tf.log(res), reduction_indices=[1]))
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)

prediction = tf.argmax(res,1)
correct_prediction = tf.equal(prediction, tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

sess = tf.Session()
with sess.as_default():
sess.run(tf.initialize_all_variables())

for step in range(300):
batch_x=[[random.randint(0, 100) for j in range(3)] for i in range(100)]
batch_y=[[int(j==np.argmax(batch_x[i])) for j in range(3)] for i in range(100)]

sess.run(train_step, feed_dict={x: batch_x, y: batch_y})

if step%25==0:
acc=sess.run(accuracy, feed_dict={x: batch_x, y: batch_y})
print "step "+str(step)+" acc "+str(acc)

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
num3 = int(input("Enter third number: "))

p=prediction.eval(feed_dict={x: [[num1,num2,num3]]})

print("The largest number is",[num1,num2,num3][p[0]],"(at position",p[0],")")
>>
>>55359958
I keked
>>
>>55359958
And it works! It works!

andrey@Shanghai:~/nn3max$ python nn3max.py
step 0 acc 0.3
step 25 acc 0.91
step 50 acc 0.99
step 75 acc 0.99
step 100 acc 0.99
step 125 acc 0.99
step 150 acc 0.99
step 175 acc 1.0
step 200 acc 1.0
step 225 acc 1.0
step 250 acc 1.0
step 275 acc 1.0
Enter first number: 45
Enter second number: 99
Enter third number: 81
The largest number is 99 (at position 1)
andrey@Shanghai:~/nn3max$
>>
>>55358482
print(max([int(input()),int(input()),int(input())])
>>
File: 1465223028235.png (345KB, 718x620px) Image search: [Google]
1465223028235.png
345KB, 718x620px
>>55359958
I don't know if lazy or genius.

Hey Neural Network figure this out for me... I'm too lazy.
>>
>>55359139

really faggot?
>>
>>55359958
nice one dude i saw that tensorflow fizzbuzz on reddit too
>>
File: 1457084167495.jpg (16KB, 154x199px) Image search: [Google]
1457084167495.jpg
16KB, 154x199px
>>55359008

> head -n 3 | sort -nr | head -n 1
>>
>>55360083
Well, I haven't. I write it from scratch just now.
>>
female here, i'll do it in C

#include<stdio.h>

int main() ...

shit, I forggot females doesn't know how to code, sorry guys.
>>
>>55359008
don't do this it creates mustard gas
>>
>>55358482
I can't test at the moment but I think it works in python 2.
Even though python 2 is retarded and you should still use int(raw_input()) if that's your target language
>>
>>55359944
Using map for side effects considered harmful
>>
>>55360095
whatever you say :^)
>>
num = {}

for i = 1,3 do
num[i] = tonumber(io.read())

end


table.sort(num)

for i, v in ipairs(num) do
print(v)
end


like i fucking know
>>
>>55359421
It's a shame for Perl code, see >>55358414 for a correct one.
>>
>>55359979
>>55359958
I train the model on numbers ranging from 0 to 100.
When I train it on numbers in range 0-1000, it does not learn anything. Sits as 33% accuracy.
But!
But it works on arbitrarily large numbers!
I'm not sure how to explain this.

Enter first number: 44444
Enter second number: 55555555
Enter third number: 777
The largest number is 55555555 (at position 2)
[[ 0. 1. 0.]]
Enter first number: 333333
Enter second number: 567
Enter third number: 8955
The largest number is 333333 (at position 1)
[[ 1. 0. 0.]]
>>
>>55360198
No it's not. What I've written is perfectly clean and proper. Map works well with nondeterministic functions. It's no more or less harmful than reading user input in any context.
>>
 double maxInRange(double first, double second, double three)
{
if (first > second)
if (first > three)
return first;
else
return three;
else if (second > three)
return second;
else
return three;
}

OR
 std::max(one, two, three); 
>>
    .file    "big.c"
.section .rodata
.LC0:
.string "%d"
.LC1:
.string "x is the largest"
.LC2:
.string "y is the largest"
.LC3:
.string "z is the largest"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $48, %rsp
movq %rdi, -40(%rbp)
movq %rsi, -48(%rbp)
movq %fs:40, %rax
movq %rax, -8(%rbp)
xorl %eax, %eax
leaq -20(%rbp), %rax
movq %rax, %rsi
movl $.LC0, %edi
movl $0, %eax
call __isoc99_scanf
leaq -16(%rbp), %rax
movq %rax, %rsi
movl $.LC0, %edi
movl $0, %eax
call __isoc99_scanf
leaq -12(%rbp), %rax
movq %rax, %rsi
movl $.LC0, %edi
movl $0, %eax
call __isoc99_scanf
movl -20(%rbp), %edx
movl -16(%rbp), %eax
cmpl %eax, %edx
jle .L2
movl -20(%rbp), %edx
movl -12(%rbp), %eax
cmpl %eax, %edx
jle .L2
movl $.LC1, %edi
movl $0, %eax
call printf
jmp .L3
.L2:
movl -16(%rbp), %edx
movl -20(%rbp), %eax
cmpl %eax, %edx
jle .L4
movl -16(%rbp), %edx
movl -12(%rbp), %eax
cmpl %eax, %edx
jle .L4
movl $.LC2, %edi
movl $0, %eax
call printf
jmp .L3
.L4:
movl -12(%rbp), %edx
movl -16(%rbp), %eax
cmpl %eax, %edx
jle .L3
movl -12(%rbp), %edx
movl -20(%rbp), %eax
cmpl %eax, %edx
jle .L3
movl $.LC3, %edi
movl $0, %eax
call printf
.L3:
movl $0, %eax
movq -8(%rbp), %rcx
xorq %fs:40, %rcx
je .L6
call __stack_chk_fail
.L6:
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
>>
File: 0036 - Gy5UAxw.jpg (947KB, 2000x2000px) Image search: [Google]
0036 - Gy5UAxw.jpg
947KB, 2000x2000px
>>55360316
>this guy
>>
>>55360313
I was more or less joking, maybe it's idiomatic in C#, but I have never worked in a place where that would be considered a good practice.
>>
>>55360364
nevermind, that's Elixir, but my point still stands
>>
File: 1466895168959.jpg (16KB, 500x308px) Image search: [Google]
1466895168959.jpg
16KB, 500x308px
>>55360316
>>
>>55357763
WOW!
>>
My god, Java is PIG DISGUSTING
>>
>>55360316
I can do that too

    .data
.globl _camlFoo__data_begin
_camlFoo__data_begin:
.text
.globl _camlFoo__code_begin
_camlFoo__code_begin:
nop
.data
.quad 768
.globl _camlFoo
_camlFoo:
.data
.quad 4087
_camlFoo__1:
.quad _caml_curry2
.quad 5
.quad _camlFoo__fun_1010
.text
.align 4
.globl _camlFoo__fun_1010
_camlFoo__fun_1010:
.cfi_startproc
subq $8, %rsp
.cfi_adjust_cfa_offset 8
.L100:
movq %rax, %rdi
movq %rbx, %rsi
leaq _caml_compare(%rip), %rax
call _caml_c_call
.L101:
leaq _caml_young_ptr(%rip), %r11
movq (%r11), %r15
addq $8, %rsp
.cfi_adjust_cfa_offset -8
ret
.cfi_adjust_cfa_offset 8
.cfi_endproc
.text
.align 4
.globl _camlFoo__entry
_camlFoo__entry:
.cfi_startproc
subq $24, %rsp
.cfi_adjust_cfa_offset 24
.L103:
movq $1, %rax
call _camlPervasives__read_int_1309
.L104:
movq %rax, %rbx
call _caml_alloc2
.L105:
leaq 8(%r15), %rax
movq %rax, 0(%rsp)
movq $2048, -8(%rax)
movq %rbx, (%rax)
movq $1, 8(%rax)
movq $1, %rax
call _camlPervasives__read_int_1309
.L106:
movq %rax, %rbx
call _caml_alloc2
.L107:
leaq 8(%r15), %rax
movq %rax, 8(%rsp)
movq $2048, -8(%rax)
movq %rbx, (%rax)
movq 0(%rsp), %rbx
movq %rbx, 8(%rax)
movq $1, %rax
call _camlPervasives__read_int_1309
.L108:
movq %rax, %rdi
call _caml_alloc2
.L109:
leaq 8(%r15), %rbx
movq $2048, -8(%rbx)
movq %rdi, (%rbx)
movq 8(%rsp), %rax
movq %rax, 8(%rbx)
leaq _camlFoo__1(%rip), %rax
call _camlList__sort_uniq_1299
.L110:
movq $1, %rbx
call _camlList__rev_append_1029
.L111:
cmpq $1, %rax
jne .L102
leaq _camlList__1(%rip), %rax
call _camlPervasives__failwith_1005

...
>>
int a;
std::cout << "for exit print \"\\n\"" << std::endl;
std::cin >> a;
int result = 0;
while (std::cin >> a)
{
if (result < a)
result = a;
}
std::cout << "Your number is " << result;
>>
function getBig(one, two, three) {
return Math.max.apply( Math, [one, two, three] )
}

ez
>>
>>55360564

doesn't work for negatives. faggot.
>>
>>55360619
no problem for me
    int a;
std::cout << "for exit print \"\\n\"" << std::endl;
std::cin >> a;
int b = a;
int result = b;
while (std::cin >> a)
{
if (result < a)
result = a;
}
std::cout << "Your number is " << result;
return 0;
>>
>>55360619
that's what you get for not precisely defining the input set, fuccboi
>>
C:
#include <stdio.h>

int main (int argc, char* argv[]) {
int temp, max;

printf("Enter number 1: ");
scanf("%d", &max);

printf("Enter number 2: ");
scanf("%d", &temp);
if (temp > max)
max = temp;

printf("Enter number 3: ");
scanf("%d", &temp);
if (temp > max)
max = temp;

printf("The largest number is %d.\n", max);
return 0;
}


Python
print("The largest number is "  + str(max([int(input("Enter number " + str(num) + ": ")) for num in range(1,4)])) + ".")
>>
>>55358533
>user enters number less than previous two anyway
>>
>>55360364
>>55360396
It's almost always cleaner and more declarative to map things rather than manually loop through and mutate lists. And manually looping through and mutating things isn't exactly something you can do in Elixir. The only other way to do this in Elixir would be to manually use recursion, but why do that when that's just a more awkward and manual way of doing what you can do by mapping streams / lists?

Here's another way which maps stdin directly rather than using IO.gets
IO.stream(:stdio, :line)
|> Stream.take(3)
|> Stream.map(&(elem(Integer.parse(&1), 0)))
|> Enum.max()
|> IO.puts()
>>
File: js.png (10KB, 1052x1052px) Image search: [Google]
js.png
10KB, 1052x1052px
>>55357763
const Reader = require('readline-sync')
const numbers = new Array()
for (let i = 0; i < 3; i++) numbers.push(parseInt(Reader.question('Please enter a number')))
numbers.sort()
console.log('Javascript's expressiveness wins again. The number is ' + numbers[2] + '.')
>>
>>55360803
const Reader = require('readline-sync')
const numbers = new Array()
for (let i = 0; i < 3; i++) numbers.push(parseInt(Reader.question('Please enter a number')))
numbers.sort()
console.log('Javascript\'s expressiveness wins again. The number is ' + numbers[2] + '.')


Forgot to escape the quote
>>
#!/usr/bin/env ruby
input = []
3.times
input << STDIN.gets.to_i
end

puts a.max
>>
>>55360699
oh, I absolutely agree, I'm actually sad that Erlang doesn't offer this kind of flexibility.

I like that example better that your previous once
>>
>>55357763
using System;
using System.Linq;
public class Test
{
public static void Main()
{
Console.WriteLine(Console.ReadLine().Split().Select(Double.Parse).OrderBy(i=>i).Last());
}
}
>>
>>55357763
scala most concise:
List(readLine(),readLine(),readLine()).sorted.last
>>
#include <iostream>
#include <limits>

int main(){
int faggot = std::numeric_limits<int>::min();

for (int fuckyou = 0; fuckyou < 3; ++fuckyou){
int nigger = 0;
std::cin >> nigger;

if(nigger > faggot){
faggot = nigger;
}

}

std::cout << faggot;

return 0;
}
>>
>>55357763
Console.WriteLine("Enter numbers separated by a comma.");
Console.WriteLine(Math.Max(Console.ReadLine().Split(',').Distinct()));
>>
>>55361017
>>55360996
>max of strings
>>
>>55360803
>>55360867
or using Math.max()
const question = require('readline-sync').question
console.log(Math.max(question('First number?'), question('Second number?'), question('Third number?')))

Thank god for type coercion.
>>
>>55361030
derp
Console.WriteLine(Math.Max(Console.ReadLine().Split(',').Select(int.Parse).Distinct()));
>>
>>55361030
It orders correctly even with string data. Try it.
>>
>>55361055
http://ideone.com/TdAFXf
>>
>>55361051
I don't see any Math.Max overload that accepts IEnumerable.
>>
>>55361166

Fair point. though anyone who isn't using a bigInt or the equivalent is also failing on that measure.
>>
something like this is probably best

#include <iostream>
#include <string>

int main()
{
std::string c;
std::cin >> c;
int max_num = stoi(c);
for (int i = 0; i < 2; ++i) {
std::cin >> c;
int n = stoi(c);
max_num = std::max(n, max_num);
}
std::cout << max_num << std::endl;
}



it can handle negative numbers, but it still doesn't handle words


pls no stab
>>
>>55361199
>though anyone who isn't using a bigInt or the equivalent is also failing on that measure.
Wrong. Just parse your strings to any number type and it will work. Lexicographic order differs from natural number order.
>>
>>55361188
Ah yes

Console.WriteLine(Console.ReadLine().Split(',').Select(int.Parse).Distinct().Max());
>>
3.times.map{ readline.to_i }.max

meh k
>>
>>55361206
>11 SLOC
>not even prompting the user
Get on my level biatch >>55361038
>>
>>55361417
Is this scala?
>>
>>55361443
>3.times
Ruby
>>
>>55361428
yes, but can you enter the three numbers on one line?
>>
>>55361501
The first line is just an import statement, so yes :^)
>>
max(int(input()) for i in range(0, 3))
>>
fn = require('ask-first-number');
sn = require('ask-second-number');
tn = require('ask-third-number');
m = require('maximum-of-two-numbers');
console.log(m(m(fn.ask(), sn.ask()), tn.ask()));
[/console]
>>
>>55358533
>user enters 600, 700, and then 420
you fail.
>>
File: sussman shig.jpg (71KB, 500x375px) Image search: [Google]
sussman shig.jpg
71KB, 500x375px
(max (read) (read) (read))
>>
File: 1466725042127.jpg (32KB, 557x612px) Image search: [Google]
1466725042127.jpg
32KB, 557x612px
>>55361617
>>
>>55361624
or
(reduce #'max (loop for i from 1 to 3 collect (read)))
>>
>>55361611
Except those aren't real packages like in mine.
>>
>>55361624
what is sussman doing these days?
>>
File: 1467401502762.gif (4MB, 400x376px) Image search: [Google]
1467401502762.gif
4MB, 400x376px
>>55359814
Lol holy fuck
>>
>>55361652
(defmacro cancer (n)
(cons 'max (make-list n :initial-element '(read))))
(cancer 3)
>>
>>55358974
>Integer
>nextInt
>Int
Because fuck consistency
>>
>>55358482
Dont know shit in python 2.x input() yields an integer dumass
>>
File: tmp_26454-INBvStO1081516644.png (312KB, 506x662px) Image search: [Google]
tmp_26454-INBvStO1081516644.png
312KB, 506x662px
Someone needs to do asm asaptbhfam
>>
>>55362037
see >>55360561
>>55360316
>>
also who's dick do I have to suck to find an invite to blackcats ?
>>
>>55362004
Go ahead and see what input() returns when I type in "[x for x in iter(lambda: 1,2)]"
>>
>>55362063
Both of those weren't written by humans.

>>55360316 is the output of `gcc -S` for a C program, and >>55360561 is the equivalent for OCaml or something like that.
>>
I need to ensure that multiple machines hold identical linked list.
Should I just hash the list contents and compare them?
>>
>>55357763
Here you go.
print("Give me 3 numbers.")
input()
input()
input()
print("Which of them is THE HIGHEST?")
print(input())
>>
>>55357763
max(int(raw_input("enter a number ")), max(int(raw_input("enter a number ")), int(raw_input("enter a number ")))
>>
>>55357763
#/bin/bash
declare -a NUM

NUMAMOUNT=3

for ((i=1;i <= $NUMAMOUNT; i++))
do
read -p "Enter number $i: " NUM[$i]
done

HIGHESTNUMBER=${NUM[1]}
for ((i=2;i <= $NUMAMOUNT; i++))
do
if [[ ${NUM[$i]} -gt HIGHESTNUMBER ]]
then
HIGHESTNUMBER=${NUM[$i]}
fi
done

echo $HIGHESTNUMBER
>>
>>55362222

bretty gud
>>
>>55362177
Mkay, I improved it a little.
print("Give me 3 numbers")
try:
print("the answer is:")
print(max([int(input()),int(input()),int(input())]))
except ValueError as e:
print("you are a moron and don't know what number is.")
>>
>>55357763
babys first program.
>.< soooo embarrassing!!
>>
>>55362249
You can't just use a library function that fucking returns the highest number for you. That's the whole assignment.
>>
>>55362249
Actually, also shit.
print("Give me 3 numbers")
try:
print("the answer is:")
print(max([int(input()) for i in range(3)]))
except ValueError as e:
print("you are a moron and don't know what number is.")
>>
>>55362277
It's a builtin in Python.
>>
File: frogtor.png (11KB, 369x243px) Image search: [Google]
frogtor.png
11KB, 369x243px
main :: IO ()
main = print =<< maximum <$> ((\x y z -> x++y++z) <$> getD <*> getD <*> getD)
where
getD = pure . read <$> getLine :: IO [Double]
>>
>>55362241
Is it though? I'm a beginner who's very slowly moving from shell scripting to C. Other than the fact that you can change the amount of numbers to compare, I don't really know if my attempt has any quality to it.
>>
>>55357763
        static void Main(string[] args)
{
var inputs = new List<int>();
var numEntries = 3;

while(numEntries-- > 0)
{
Console.Write($"Enter a number: ");
var input = Console.ReadLine();
var inputToNum = 0;
if (int.TryParse(input, out inputToNum))
inputs.Add(inputToNum);
else
{
Console.WriteLine($"The value '{input}' is not a valid number.");
numEntries++;
}
}
Console.WriteLine($"The biggest number you entered was {inputs.Max()}");
Console.ReadLine();
}
>>
>>55362298
damn c++ is so ugly.
>>
>>55362309
nigga I hope u trollin
>>
>>55362309
It is C#
>>
>>55362287
I wouldn't care to answer *that*, really...
>>
#include <iostream>

int main() {

std::cout << "enter 3 numbers, faggot" << std::endl;
int a, b, c, d;
std::cin >> a >> b >> c;
if (a > b) {
if (a > c)
d = a;
else
d = c;
}
else if (b > c)
d = b;
else
d = c;
std::cout << d << " is the highest, bitch" << std::endl;
}
>>
>>55362332
>>55360315
>>
Thank you oh Universe for being benevolent to me and not making me to write c/cpp/c#/java and especially basic.
>>
File: 1323635452001.png (6KB, 344x326px) Image search: [Google]
1323635452001.png
6KB, 344x326px
>Using built-in constructs/library functions to get a highest number
>Using a "list sorter" for other purposes than moving the elements in an array around
>Putting more than one of the logical steps to determine the highest number in the same line
>Putting the input prompt and the calculations in the same line
>Putting the output and the input prompt in the same line

I feel sick.
>>
>>55362332
>>55362358
improved version for robot-testing
#include <iostream>
#include <algorithm>

int main() {
int a, b, c;
std::cin >> a >> b >> c;
std::cout << max(a, b, c) << std::endl;
}
>>
>>55357763
was thinking of doing it with logic gates but I'm too lazy
>>
>>55362416
sorry, its
std::max();
>>
>>55362390
A fucking armed bird is threatening to kill me if I don't this!
Of course, I'm using any shortcut available.
>>
#include <iostream>

int main()
{
int n[3];
std::cout << "Numbers: ";
std::cin >> n[0] >> n[1] >> n[2];

if(n[0]>n[1] && n[0]>n[2]) std::cout << n[0];
else if(n[1]>n[0] && n[1]>n[2]) std::cout << n[1];
else std::cout << n[2];
}



▲ ▲
>>
>>55362448
Yeah but I think the bird wants to test that you're able to do it on your own. What people are doing here is pretty much just proving that they can ask for user input 3 times in a row.
>>
>>55362467
It appears to me that only speed is of the essence here.
>>
>>55362467
I wouldn't be so pessimistic. It rather proves that people are just not dumb enough to invent another bicycle instead of using max()
>>
>>55358614
Neato
>>
File: max.png (2MB, 842x644px) Image search: [Google]
max.png
2MB, 842x644px
PLC version
>>
>>55362390
You can't expect the right answer to the wrong question.
>>
>>55359530
>why would anyone want to use python2?

are you new to python?
>>
>>55362543
It's not about whether the answer is right, it's about whether your code is legible and you're able to pull off a very simple algorithm without having your hand held by momma library.
>>
>>55362607
Point me to where OP said that.
I'll wait.
>>
File: vb.png (42KB, 1010x758px) Image search: [Google]
vb.png
42KB, 1010x758px
>>
>>55362618
OP didn't. I commented on people's shit code on my own initiative. It's shit.
>>
>>55362693
It's shit because it doesn't reinvent the wheel for absolutely no reason?
>>
>>55362607
Okay, specially for those who hate using built-in features more complex than a loop.
max = None
for i in range(3):
val = input()
max = (not max or max < val) and val or max
But it's just unreadable, sick, slow and retarded in every way.
>>
File: a.png (760B, 24x78px) Image search: [Google]
a.png
760B, 24x78px
>>55362669
you better not be hacking my IP with your visual basic gooey to get access to my command prompt through my telephone
>>
>>55362746
>(not max or max < val)
You should assign the first value to max and then compare it to the remainder of the values. That "not max or" adds extra cpu cycles to every iteration.
>>
print(max(input(), input(), input()))


Python master-race.
>>
>>55362795
>implying amimanus ever forgives and/or forget
WAIT FOR OUR HAPPENING
>>
>>55362884
Compilers should punish anyone trying to get user input and output it to stdout in the same line of code by deleting their home folder
>>
>>55357763
I'm not a programmer but here's my algorithm:

public autistic void main (memespeak[], java_is_garbage_but_faster_than_python){

//Obtain inputs
int number_of_inputs = 3;
float[] inputs = new float[number_of_inputs];

for (int i = 0, i<=number_of_inputs, i++){
input.add(float(??("Enter your number: "+i+"/"+number_of_inputs))); //whatever the fuck they use for user prompt and adding floats to an array
}

//Post result
system.out.println("Thanks, your maximum input was: "+max(inputs)); //or whatever the fuck they use for getting the max value in an array
}


lel I forgot everything.
>>
>>55358303
acknowledged
>>
one = int(input("enter the first number")
two = int(input("enter the second number")
three = int(input("enter the third number")
if one > two and one > three:
print(one)
if two > one and two > three:
print(two)
if three > two and three > one:
print(three)

maybe no my favorite but the easiest
>>
>>55361772
nextInt returns an int, not an Integer.
>>
>>55363070
lol
CSgraduate.png
>>
>>55358614
Is this an actual language?
>>
File: the coolest.png (760KB, 1920x1080px) Image search: [Google]
the coolest.png
760KB, 1920x1080px
>>55357763
>>
>>55363111
of course
>>
>>55358042
>>55357763

u wot

import java.util.Scanner;

public class oopIsAFaggot {
public static void main(String[] args) {
System.out.println("Enter 3 numbaz for I cap yo ass cuzz");
Scanner s = new Scanner(System.in);
Integer one = s.nextInt(), two = s.nextInt(), three = s.nextInt();
s.close();
System.out.println(one >= two && one >= three ? one : two >= one && two >= three ? two : three);
>>
var x = prompt("Input 1st value");
var y = prompt("Input 2nd value");
var z = prompt("Input 3rd value");

Math.max(x, y, z);
>>
>>55357912
>>55358482
Fixed
print(max([int(input('number: ')) for n in range(3)]))
>>
>>55358614
Brainfuck? Amazing.
Would you mind add some comments to it?
>>
>>55357763
puts "Print highest number homework\n   Type numbers (space separated):"
a = gets.split.map(&:to_i)
print "Highest is: #{a.max}\n"
>>
var x1 = prompt(), x2 = prompt(), x3 = prompt();
alert(Math.max(x1,x2,x3));
>>
Kisamaa
>>
def number_input():
try:
return int(input("Enter a number: "))
except ValueError:
print("Try again fucking retard.")
return number_input()

print(max(number_input() for _ in range(3)))
>>
>>55364079
it has comments already!! now that's brainfuck !!
>>
>>55362467
>Yeah but I think the bird wants to test that you're able to do it on your own.

Projecting, much? Since when have you become an expert on killer birds?
>>
>>55359958
This is quite short considering everything it does under the hood. These new machine learning libraries are neat.
>>
# Call with Rscript file.R n1 n2 n3
options(stringsAsFactors=FALSE)
args <- commandArgs(trailingOnly = TRUE)
args <- suppressWarnings(as.numeric(args,na.rm=TRUE))is.na

if (! length(args) == 3) {
stop("You did not provide exactly three arguments.")
} else if (any(is.na(args))) {
stop("You provided a non-numeric argument.")
}

print("The maximum value is ",max(args),".",sep="")
>>
>>55358042
>It's not homework you idiot.
just keep saying that, people here will do your homework for you.

i passed a whole class by just getting /g/ to do my homework for me, nerds lol
>>
I'd solve it in TIS-100, but I'm camping and I don't have it on here.
>>
>>55364801
woop, that extra is.na on line four shouldn't be there
>>
>>55364890
>camping
>on 4chan
I'd beat you if I was your dad
>>
>>55360658
These are the only languages you need. Maybe throw in some LISP too.
>>
>>55363165

>programming monster

Top kek
>>
kek I believe this was one of the exercises in one of my Assembly exams
>>
>>55357763
#include <iostream>

int main() {
int numbers[3];
int max = 0;

for (int i = 0; i < 3; i++) {
std::cout << "Enter a number: ";
std::cin >> numbers[i];
}

for (int i = 0; i < 3; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}

std::cout << std::endl << "The max number is " << max << std::endl;

return 0;
}
>>
>>55365208
-3 -6 -2

ans: 0

HMMMM IT REALLY MAKES YOU THINK
>>
>>55365208
>>55365245
The skills of this generation of programmers are cancer
>>
>>55365245
Ok, is this better?

#include <iostream>

int main() {
int numbers[3];
int max;

for (int i = 0; i < 3; i++) {
std::cout << "Enter a number: ";
std::cin >> numbers[i];
}

max = numbers[0];

for (int i = 0; i < 3; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
}

std::cout << std::endl << "The max number is " << max;

return 0;
}
>>
>>55365407
>>
>>
>>55360228
>>55361541
>using the smiley with a carat nose
>>
>>55357763
replicateM 3 readLine >>= print . maximum


took me about 3 seconds. untested
>>
>>55365621
is Hasklel worth learning for some audio programming and DSP??
>>
>>55365621
damn, I knew I was missing something.

replicateM 3 (readLn :: IO Integer) >>= print . maximum


actually tested this time
>>
>>55365640
netwire is pretty fun for DSP

https://github.com/ocharles/netwire-classics/blob/master/asteroids/Sounds.hs
>>
>>55365679
but I mean like, can Haskell do some low level stuff like messing with ALSA, calling C functions and system calls?
>>
>>55365716
Haskell has a pretty strong C FFI, one of the best out there for being such a high level language
>>
>>55365716
>>55365729
https://hackage.haskell.org/package/alsa-pcm

you mean like this?
>>
>>55365756
I'm more concerned about how that actually wraps the alsa api
>>
const int main[] = {
-443987883, 440, 113408, -1922629632,
4149, 899584, 84869120, 15544,
266023168, 1818576901, 1461743468, 1684828783,
-1017312735
};

64bit linux
>>
>>55365778
>I'm more concerned about how that actually wraps the alsa api
https://hackage.haskell.org/package/alsa-pcm-0.6.0.4/docs/src/Sound-ALSA-PCM-Core-Handle.html#open

Also check out these for some more high-level DSP/audio stuff
https://hackage.haskell.org/package/synthesizer
https://hackage.haskell.org/package/haskore
>>
File: scratch1.png (28KB, 305x492px) Image search: [Google]
scratch1.png
28KB, 305x492px
ez
>>
File: kqOAoqg.png (615KB, 665x661px) Image search: [Google]
kqOAoqg.png
615KB, 665x661px
>>55357763

I wanted to be obscure so I used qbasic, and it doesn't have a fucking max function. what the hell, bill gates. what were you thinking.

CLS
DIM values(3) as INTEGER
INPUT "Enter 1st integer", values(1)
INPUT "Enter 2nd integer", values(1)
INPUT "Enter 3rd integer", values(1)
max = values(1)
FOR x = 2 TO 3
IF values(x) > max THEN max = values(x)
NEXT x
PRINT "Max value is:"
PRINT max


Jesus it's so much easier in a modern language like R.

values <- rep(0, 3)
n1 <- readline(prompt="Enter 1st integer: ")
n2 <- readline(prompt="Enter 2nd integer: ")
n3 <- readline(prompt="Enter 3rd integer: ")
print(paste("Max value: ", max(values), sep=""))
>>
here's mine
scanf sucks for user input, but oh well

[/code]
#include <stdio.h>
int max(int a, int b) {
if (a > b) return a;
return b;
}
int main() {
int a,b,c;
printf("type three numbers separated by spaces: ");
scanf("%d%d%d",&a,&b,&c);
printf("the biggest is: %d\n",max(a, max(b,c)));
}
[/code]
>>
>>55365988
that image is cancer
>>
File: oops.gif (1023KB, 366x350px) Image search: [Google]
oops.gif
1023KB, 366x350px
>>55366246
whoops
#include <stdio.h>
int max(int a, int b) {
if (a > b) return a;
return b;
}
int main() {
int a,b,c;
printf("type three numbers separated by spaces: ");
scanf("%d%d%d",&a,&b,&c);
printf("the biggest is: %d\n",max(a, max(b,c)));
}


not like it matters that much
>>
>>55357763
AAAA
package main

import (
"fmt"
"math"
)

func main() {
fmt.Println("ENTER THREE NUMBERS:")
nums := []float64{}
for len(nums) != 3 {
var num float64
_, err := fmt.Scanf("%f", &num)
if err != nil {
fmt.Println("ERROR", err)
} else {
nums = append(nums, num)
fmt.Println("OK")
}
}
fmt.Println("HIGHEST:", math.Max(math.Max(nums[0], nums[1]), nums[2]))
}
>>
Hello user, please give me three numbers and I'll give you back the highest number.
>>
>>55365988

im babby at R (not a coder, political "scientist") but check mine

fun1 <- function(x, y, z) {
a <- max(x, y, z)
print(a)
}
>>
>>55357763
Wolfram Language (a shit proprietary language)

CloudDeploy[
FormFunction[{{"num1", "Enter Number 1:"} -> "Number", {"num2", "Enter Number 2"} -> "Number",{"num3", "Enter Number 3"} -> "Number"},
Row[{"Maximum: ",Max[{#num1, #num2,#num3}]}]&,"PNG"]]


Result: https://www.open.wolframcloud.com/objects/b62c464b-be15-434e-aff7-a074e09e94ba
>>
>>55366465
you don't get bonus points for deploying your “maximum app” on the “cloud”. Not even if you make a docker container for it
>>
>>55366465
>>55366648

cant see it anyway, dont have "permission"
>>
>>55366648
That's why it is a shit language. I just did it, because I was already working with it
>>55366748
Didn't notice it:
Go there: https://develop.open.wolframcloud.com/app/
Create a new notebook -> Copy-Paste -> shift enter -> copy link in browser
Should work
>>
File: 1436913873073.png (375KB, 600x443px) Image search: [Google]
1436913873073.png
375KB, 600x443px
>>55366431

> max(x,y,z)

this is REALLY nit-picky, but you're using outdated syntax here. it's still supported, but you should be passing only one argument to max() as a vector, not as 3 separate scalar arguments. so
max(x(1,2,3))

is better practice than
max(1,2,3)
.
same is true with sum(). The ability do do what you did is a leftover from S.

>>55365988
I actually fucked up my code because I decided too late that I was going to pre-allocate my array (always good practice) and forgot to finish doing so.

values <- rep(0, 3)
values [1] <- readline(prompt="Enter 1st integer: ")
values [2] <- readline(prompt="Enter 2nd integer: ")
values [3] <- readline(prompt="Enter 3rd integer: ")
print(paste("Max value: ", max(values), sep=""))


A more user-friendly way to do this is to ask the user for a string of 3 integers, separated by spaces.

val_str <- readline(prompt="Enter numbers, separated by commas (,) : ")
vals <- as.numeric(strsplit(val, split=','))
print(paste("max value: ", max(vals), sep=""))
>>
>>55360899
puts 3.times.collect { gets }.max
>>
>>55366977
>x(1,2,3)

that x should be a c. fucking qwerty.
>>
>>55367015
yea just noticed that playing with it myself, thanks!
>>
pro supgents
read, "enter 3 comma-separated numbers", niggers
print, max(niggers)
end
>>
>>55357763

if(first())
{
runOnChat(1)

print("Enter 3 numbers separated by spaces into chat")
}

if(chatClk(owner()))
{
Nums = owner():lastSaid():explode(" ")
A = Nums[1, string]:toNumber()
B = Nums[2, string]:toNumber()
C = Nums[3, string]:toNumber()

if(A > B & A > C) { print(A) }
elseif(B > A & B > C) { print(B) }
elseif(C > A & C > B) { print(C) }
}
>>
>>55357763
#include <stdio.h>
int main(){

}


Kill me Mr. bird, plox.
>>
>>55358533
thank you for making me kek really hard
'cause I know there are people out there who would unironically write a program like this one
>>
>>55358774
oh Pascal haven't seen it in years are there people out there who are acctually still using it ?
>>
>>55357763
#include<stdio.h>
#include<stdlib.h>
int a,b,c;
int main()
{
printf("introduisez les valeurs de a b et c");
scanf("%d %d %d",&a,&b,&c);
printf("le max est : %d",(a>b)?a:(b>c)?b:c);
}
>>
>>55358050
What language is this?
>>
>>55368410
what the fuck is this shit
>>
>>55368190
Some places use it for teaching. I learned a long time and only use it occasionally for fun when I want to get away from java.
>>
>>55366977
>other R coders on /g/
BROTHER
>>
>>55357763
uhh... uhh...

print max([int(input('number {}?\n'.format(x))) for x in range(3)])
>>
>>55362884
3
100
201
3


Thanks for the great code anon.
>>
File: 25108774.jpg (88KB, 400x400px) Image search: [Google]
25108774.jpg
88KB, 400x400px
what the fuck is a vector?
>>
SPECIAL BONUS!!! WRITE IN APPLESCRIPT!!! MAHAHA!!!
>>
File: chad.png (739KB, 620x616px) Image search: [Google]
chad.png
739KB, 620x616px
>>55357763
main = do 
nums <- sequence $ replicate 3 (putStr "number?: " >> getLine)
print $ maximum (map (\x -> read x :: Int) nums)
>>
>>55368263
greek assembly derivative from 4chan's "4code"
>>
>>55357763
print(max(int(input(":")),int(input(":")),int(input(":"))))
>>
>>55357763

DIM NUM(1 to 3) as LONG
DIM Biggest as LONG
DIM I AS INTEGER
Input "Enter 3 numbers: ", NUM(1), NUM(2), NUM(3)

Biggest = NUM(1)
FOR I = 1 to 3
if( NUM(I) > Biggest )
Biggest = NUM(I)
NEXT I
Print "Biggest number is: " ; Biggest


>>
>>55369107
I thought basic was a fake memory of my fucked up adolescence because its existence seemed too absurd to me.
>>
>>55362288
why use applicatives, u made it too complicate my dawg
>>
>>55369101
what language
>>
>>55369181
Python
>>
>>55357763
No error checking because fuck that
include <stdio.h>

int main()
{
const int amountNums = 3;
int nums[amountNums];
for(int i = 0; i < amountNums; ++i)
{
printf("Enter number %d: \n", i + 1);
scanf("%d", &nums[i])
}
int max = 0;
int index = 0;
for(int i = 0; i < amountNums; ++i)
{
if(nums[i] > max)
{
max = nums[i];
index = i;
}
}
printf("Number %d is the largest", index + 1);
}
>>
if($howtouse4chancodeong) do; true
else; $time


help
>>
>>55359530
>why would anyone use python2?

>being this retarded
>>
>>55369283
If everything ist negative, then 0 is the biggest
>>
>>55369490
here is an improved version
include <stdio.h>

int main()
{
const int amountNums = 3;
int nums[amountNums];
int max = 0;
int index = -1;
for(int i = 0; i < amountNums; ++i)
{
printf("Enter number %d: \n", i + 1);
scanf("%d", &nums[i]);
if(nums[i] > max || index == -1)
{
max = nums[i];
index = i;
}
}
printf("Number %d is the largest", index + 1);
}
>>
File: tom-sawyer.jpg (61KB, 435x402px) Image search: [Google]
tom-sawyer.jpg
61KB, 435x402px
oh, so we're all doing your comp sci homework for you now? our latest 20-something year old manager bullshitted his way into his job after lazing his way to a degree using your method. his 85-k-a-year job lasted all of 3 days. he will NEVER get another chance.

study harder.
>>
>>55357763
print("ENTER THREE NUMBERS")
print("THE HIGHEST")

>tfw i technically shouldn't be stabbed
>>
>>55369655
If you think this is what computer science homework is like then you've never taken a computer science course.
>>
File: 0b4.gif (123KB, 566x584px) Image search: [Google]
0b4.gif
123KB, 566x584px
>>55362669
>vb.jpg
>not cancer.jpg
You disgust me.
>>
>>55369687
Only correct answer in the entire thread.
>>
No error checking? No scalability? Non of you shits will make it in the industry

var times = 3;
var input = []
while(input.length < times) {
var user = parseInt(prompt((input.length + 1) + " enter a number"));
if(isNaN(user)) alert("That shit didnt count");
else input.push(user);
}
alert("Max is " + Math.max(...input));
>>
>>55357763
I'm boring

#include <stdio.h>

int main(void)
{
int highest = 0, i = 2, num;
scanf(" %d", &highest);
while (i--) {
scanf(" %d", &num);
if (num > highest)
highest = num;
}
printf("%d is highest\n\n", highest);
}
>>
>>55370061
In retrospect, I didn't need to initialize highest..
>>
import java.util.scanner;

Scanner sc = new Scanner(System.in);
int one = sc.nextInt();
int two = sc.nextInt();
int three = sc.nextInt();

System.out.println(Math.max(one, Math.max(two, three)));
>>
Everyone here is doing input and sort separately but you store variables you'll never use again so why not just check after each input?
>>
>>55357763
#include <studio.h>

int main(void)
{
int a, b, c;
printf("Please input 3 numbers: ");
scanf("%d, %d, %d", &a, &b, &c);
printf("The biggest number is: %d", a > b ? a : b > c ? b : c);
return 0;
}
>>
>>55370074
Yes you did. highest isn't guaranteed to be 0, and will occasionally be garbage, and therefore has a chance to be higher than any input number
>>
>>55370222
It shouldn't matter what highest is initialized to, because its value isn't used until filled in by the user. So it shouldn't matter what garbage value was in it.
>>
File: ZWvyL3k.png (11KB, 938x124px) Image search: [Google]
ZWvyL3k.png
11KB, 938x124px
>Hard coding a limited number of inputs

Why / Why
>>
>>55362669
vb6 4 lyfe
>>
>>55370472
static void Main(string[] args)
{
Console.Write("Please enter some space-seperated integers: ");
int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), s => int.Parse(s));
Console.WriteLine($"Largest integer: {input.OrderByDescending(i => i).ToArray()[0]}");
Console.ReadKey();
}


Now with some instructions.
>>
>>55357763
print "Enter 3 numbers"
print gets.split(' ').sort.last
>>
>>55370580

Python one-liners are where it's at. (I'm not a Python programmer. This may be Ruby for all I know)
>>

#include <string>
#include <iostream>
#include <stdlib.h>
using namespace std;

int main() {
string input;
int numarr[3] = {0,0,0};
for (int x = 0; x < 3; x++) {
cout << "Favorite Number #" << x+1 << ":";
getline(cin, input);
numarr[x] = atoi(input.c_str());
}
int largestVal = numarr[0];
for (int x = 0; x < 3; x++) {

if (largestVal < numarr[x]) {
largestVal = numarr[x];
}
}
cout << endl<< "Largest:" << largestVal;


}
>>
>>55361206
I didn't have c++11.
>>
>>55357763
C++11
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

int main(void)
{
std::vector<int> v;

for(int i = 0; i < 3; i++)
{
std::cout << "Enter a number: ";
std::string s;
std::getline(std::cin, s);
std::cout << std::endl;
int num;

std::stringstream ss(s);
if(!(ss >> num))
{
i--;
std::cerr << "Not a valid number! Try again!" << std::endl;
}

else
{
v.push_back(num);
}
}

std::sort(v.begin(), v.end(), std::greater<int>());

std::cout << v[0] << std::endl;
}
>>
>>55370799
I tested this, and it works even if you put negatives and strings in.
>>
>>55370100
>no math import
>>
>>55370640
It's ruby and it should be gets.split(' ').max
>>
>>55357763
Every time I see this thread, I want to write factory hell in java just for giggles, but I am too lazy to do so.
>>
File: 8d986b0a8.jpg (35KB, 400x284px) Image search: [Google]
8d986b0a8.jpg
35KB, 400x284px
>>55357763
por favor, introduzca los tres números e imprimir el más alto
>>
print max([input(),input(),input()])


Can it be smaller in Python2?
>>
>>55371421
Someone already posted
print max(input()for _ in range(3))
>>
>>55371472
fuck
>>
>>55357763
#include <stdio.h>
#include <stdlib.h>
#define NUM 3
int main()
{
int in = 0, buf, i;
for (i = 0; i<NUM; i++)
{
scanf("%d", &buf);
if (buf > in)in =buf;
}
printf("%d", in);
return 0;
}
>>
>>55370466
Oh you're right. Turns out I was the garbage value all along
>>
print("enter three numbers plox")
print("THE HIGHEST")
>>
>>55371682
print("enter three numbers plox\nTHE HIGHEST


dummy
>>
>>55371697
thats some strate demo code shit.
>>
>>55360658
Pretty underrated code right here. First solution like this.

I like it. Thanks for posting.
>>
>>55371510
Doesn't work with negative inputs. Also stdlib seems unneeded.
>>
print(max([int(i) for i in raw_input('Enter numbers: ').split()]))
>>
>>55357763
#include <stdio.h>

#define NUMS 3

int max(int *array)
{
int i, max;
max = array[0];

for (i = 0; i < NUMS - 1; i++) {
if (array[i + 1] > max)
max = array[i + 1];
}

return max;
}

int main(void)
{
int i, array[NUMS];

for (i = 0; i < NUMS; i++)
scanf("%d", &array[i]);

printf("%d\n", max(array));

return 0;
}
>>
>>55370180
>#include <studio.h>
wew lad
> <stdio.h> BTFO
>>
I'm just starting, pls don't judge me bird-sama
num1 = float(input("Enter a number"))
num2 = float(input("Enter another number"))
num3 = float(input("Enter a third number"))
highest = num1
if num2 > highest:
highest = num2
if num3 > highest:
highest = num3
print (highest)


I also just realized that I could cut out a line by just replacing the num1 variable entirely with highest.
>>
File: zKYAVXC.jpg (73KB, 576x768px) Image search: [Google]
zKYAVXC.jpg
73KB, 576x768px
FUCKING NERDS
>>
 ?- read([X,Y,Z]), max_list([X,Y,Z],Max), write(Max).
|: [3,4,2].
4
X = 3,
Y = 4,
Z = 2,
Max = 4.
>>
>>55372165
I'm guessing you are one of those summerfags who shitpost about /v/ tier GPUs? /g/ is literally for nerds, before summer there wasn't /v/ kids here, well not always like now, they were here sometimes but they weren't literal children.
>>
File: 1450212998898.jpg (29KB, 490x333px) Image search: [Google]
1450212998898.jpg
29KB, 490x333px
>>55372165
>I'm not clever or patient enough to teach myself objectively useful skills like programming
>>
#include <stdio.h>

int main() {
int a, b, c;
printf("First number: ");
scanf("%d", &a);
printf("Second number: ");
scanf("%d", &b);
printf("Third number: ");
scanf("%d", &c);

if ((a > b) && (a > c))
printf("%d\n", a);
else if (c > a)
printf("%d\n", c);
else
printf("%d\n", b);
return 0;

}


There you have kid.
And now try to improve it and learn why scanf is bad.
>>
use std::io::*;
use std::i64;

fn main() {
let max = (0..3).map(|_| {
println!("Gib number: ");
let mut s = String::new();
stdin().read_line(&mut s).unwrap();
i64::from_str_radix(&s.trim(), 10).unwrap()
}).max().unwrap();

println!("Max: {}", max);
}
>>
File: xd.jpg (24KB, 499x499px) Image search: [Google]
xd.jpg
24KB, 499x499px
>>55358050
>6 comparisons
>>
Was this even a challenge?

C#
Enumerable.Range(0, 3)
.Select(i =>
int.Parse(Console.ReadLine()))
.Max()


Look at javas examples, ayyylmao!
Thread posts: 326
Thread images: 35


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.