간단한 구구단
Bash
bash
read n
for i in {1..9}; do
echo $n \* $i = $((n * i))
done
1
2
3
4
2
3
4
C
c
#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
for (int i=1; i<=9; i++) {
printf("%d * %d = %d\n", n, i, n*i);
}
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Node.js
javascript
let n = Number(require("fs").readFileSync(0).toString().trim());
for (let i=1; i<=9; i++) {
console.log(`${n} * ${i} = ${n*i}`);
}
1
2
3
4
2
3
4
PHP
php
<?php
fscanf(STDIN, "%d", $n);
for ($i=1; $i<=9; $i++) {
echo "$n * $i = ".$n*$i."\n";
}
?>
1
2
3
4
5
6
2
3
4
5
6
Python3
python
n = int(input())
for i in range(1, 10):
print("{} * {} = {}".format(n, i, n*i))
1
2
3
2
3
Ruby
ruby
n = gets.chomp.to_i
for i in 1..9
puts "#{n} * #{i} = #{n*i}"
end
1
2
3
4
2
3
4
Comments
Not supported comment edit and upvote
You can do it on this page if you want.