"STDIN 정수 배열(가로) 입력 받기"의 두 판 사이의 차이

9번째 줄: 9번째 줄:
<source lang='C'>
<source lang='C'>
#include <stdio.h>
#include <stdio.h>
#include <ctype.h>


struct numTag {
struct numTag {

2018년 8월 14일 (화) 00:25 판

1 개요

STDIN 정수 배열(가로) 입력 받기
입력값 예시
19 3 12 28

2 C

#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;
}

3 C#

int[] a = Console.ReadLine().Split(' ').Select(x=>Convert.ToInt32(x)).ToArray();

4 Perl

@nums = split / /, <>;

5 PHP

$nums = explode(' ', rtrim(fgets(STDIN)));
$nums = array_map('intval', explode(' ', fgets(STDIN)));

6 Python

nums = list(map(int,input().split()))
print( nums )
# [19, 3, 12, 28]
nums = [int(e) for e in input().split()]
print( nums )
# [19, 3, 12, 28]
nums = [int(e) for e in input().split(' ')]
print( nums )
# [19, 3, 12, 28]
nums = input().split()
print( nums )
# ['19', '3', '12', '28']
nums = map(int,input().split())
print( nums )
# <map object at 0x7fd92c102908>
for num in nums:
    print( num, end=' ')
# 19 3 12 28

7 Swift

let nums = readLine()!.components(separatedBy: " ").map{ Int($0)! }

8 같이 보기

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