BOJ 1008 A/B

1 개요[ | ]

BOJ 1008 A/B

[[분류:BOJ {{{단계}}}단계]]

  • 1단계
  • 두 수의 나눗셈
  • 알고리즘 분류: 사칙연산

2 C[ | ]

#include <stdio.h>
int main() {
	int a, b;
	scanf("%d %d",&a,&b);
	printf("%.9f\n",1.0*a/b);
	return 0;
}
#include <stdio.h>
int main() {
	double a, b;
	scanf("%lf %lf",&a,&b);
	printf("%.9f\n",a/b);
	return 0;
}

3 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    double a, b;
    cin >> a >> b;
    printf("%.9f\n", a/b);
    return 0;
}

4 C#[ | ]

using System;
public class Program {
    public static void Main() {
        string s = Console.ReadLine();
        string[] ss = s.Split();
        double a = double.Parse(ss[0]);
        double b = double.Parse(ss[1]);
        Console.WriteLine(a/b);
    }
}

5 CMD[ | ]

@echo off
set /p line=
for /f "tokens=1" %%G IN ("%line%") DO set a=%%G
for /f "tokens=2" %%G IN ("%line%") DO set b=%%G
set /a "c=%a%/%b%"
echo %c%

6 Go[ | ]

package main
import "fmt"
func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Printf("%d\n", a/b)
}

7 Java[ | ]

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        System.out.println(a / b);
    }
}

8 node.js[ | ]

var fs = require('fs');
var input = fs.readFileSync('/dev/stdin').toString().split(' ');
var a = parseInt(input[0]);
var b = parseInt(input[1]);
console.log(a/b);

9 Perl[ | ]

my ($a, $b) = split(/ /, <>);
print $a / $b;
$_=<>;
s# #/#;
print eval;

10 PHP[ | ]

<?php
fscanf(STDIN,"%d %d",$a,$b);
fprintf(STDOUT,"%s",$a/$b);
<?php
fscanf(STDIN,"%d %d",$a,$b);
echo $a/$b;

11 Python[ | ]

a, b = map(int, input().split())
print(a/b)

12 R[ | ]

x=scan("stdin")
cat(sprintf('%.9f',x[1]/x[2]))
x = scan("stdin")
a = x[1]
b = x[2]
cat(sprintf('%.9f', a/b))

13 Ruby[ | ]

a, b = gets.split
puts a.to_f / b.to_f

14 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}