1 개요[ | ]
- STDIN 정수 배열(가로) 입력 받기
표준입력
text
Copy
19 3 12 28
2 Bash[ | ]
Bash
Copy
read n
echo $n
# 19 3 12 28
Bash
Copy
read n
for s in $n
do
echo $s
done
#19
#3
#12
#28
3 C[ | ]
C
Copy
#include <stdio.h>
struct numTag {
int num[256];
int size;
};
int main()
{
struct numTag sNum = {{0, } , 0};
int a;
do {
scanf("%d", &sNum.num[sNum.size++]);
} while (getc(stdin) != '\n');
return 0;
}
4 C#[ | ]
C#
Copy
int[] a = Console.ReadLine().Split(' ').Select(x=>Convert.ToInt32(x)).ToArray();
5 Perl[ | ]
Perl
Copy
@nums = split / /, <>;
6 PHP[ | ]
PHP
Copy
$nums = explode(' ', rtrim(fgets(STDIN)));
PHP
Copy
$nums = array_map('intval', explode(' ', fgets(STDIN)));
PHP
Copy
$nums = array_map('intval', preg_split('/ /', trim(fgets(STDIN)), -1, PREG_SPLIT_NO_EMPTY));
7 Python[ | ]
Python
Copy
nums = list(map(int,input().split()))
print( nums )
# [19, 3, 12, 28]
Python
Copy
nums = [int(e) for e in input().split()]
print( nums )
# [19, 3, 12, 28]
Python
Copy
nums = [int(e) for e in input().split(' ')]
print( nums )
# [19, 3, 12, 28]
Python
Copy
nums = input().split()
print( nums )
# ['19', '3', '12', '28']
Python
Copy
nums = map(int,input().split())
print( nums )
# <map object at 0x7fd92c102908>
for num in nums:
print( num, end=' ')
# 19 3 12 28
8 Swift[ | ]
swift
Copy
let nums = readLine()!.components(separatedBy: " ").map{ Int($0)! }
9 같이 보기[ | ]
편집자 Jmnote John Jeong Ykhwong
로그인하시면 댓글을 쓸 수 있습니다.