AWK (32)
{m=3ドル-2ドル;print m/=2ドル-1,ドル2ドル-1ドル*m}
Demo: http://ideone.com/kp0Dj
bash (38)
awk '{m=3ドル-2ドル;print m/=2ドル-1,ドル2ドル-1ドル*m}'
Demo: http://ideone.com/tzFi8
DOS/BATCH (55)
set/a m=(%3-%2)/(%2-%1)&set /a n=%2-%m%*%1&echo %m% %n%
Takes parameters as space-separated list of arguments.
Java (185)
import java.util.*;class R{public static void main(String[] m){Scanner s=new Scanner(System.in);int a=s.nextInt(),b=s.nextInt(),c=s.nextInt()-b;c/=b-a;System.out.print(c+" "+(b-a*c));}}
Demo: http://ideone.com/Lltzh
Note that ideone requires the java class name to be Main, but that is the only difference between the demo code and my solution.
JavaScript (47 (削除) 48 (削除ここまで) (削除) 61 (削除ここまで) (削除) 67 (削除ここまで))
m=p(b=p(a=p(p=prompt)))-b;alert([m/=b-a,b-a*m])
Demo: http://jsfiddle.net/BT8bB/6/
PHP (77)
<?fscanf(STDIN,'%d %d %d',$x,$y,$z);$a=($z-$y)/($y-$x);echo$a." ".($y-$a*$x);
Demo: http://ideone.com/lyiT0
QBasic (34)
INPUT a,b,c
m=(c-b)/(b-a)
?m;b-m*a
TI-83 Basic (41)
:Prompt A,B,C
:(C-B)/(B-A→M
:Disp M,B-A*M
Yes, the missing right parenthesis is on purpose. It's a well-known optimization technique that closing the parentheses before a STO operation is not necessary in TI-83 Basic programming.
- 6.1k
- 3
- 28
- 34