"BOJ 15552 빠른 A+B"의 두 판 사이의 차이

 
(사용자 2명의 중간 판 7개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
* {{BOJ|15552}}
{{BOJ|단계=3}}
* https://www.acmicpc.net/board/view/22716


{{BOJ 단계 헤더}}
==C==
{{BOJ 3단계}}
<syntaxhighlight lang='c'>
{{BOJ 단계 푸터}}
#include <stdio.h>
int main() {
int T;
scanf("%d", &T);
int A, B;
for(int tc=1; tc<=T; tc++) {
scanf("%d %d", &A, &B);
printf("%d\n", A+B);
}
}
</syntaxhighlight>


==Bash==
==C++==
<source lang='bash'>
<syntaxhighlight lang='cpp'>
read n
#include <iostream>
for sth in `seq 1 $n`
using namespace std;
do
int main() {
     read b
int T;
     echo $b | awk '{print $1+$2}'
scanf("%d", &T);
done
int A, B;
</source>
for(int tc=1; tc<=T; tc++) {
scanf("%d %d", &A, &B);
printf("%d\n", A+B);
}
}
</syntaxhighlight>
<syntaxhighlight lang='cpp'>
#include <iostream>
using namespace std;
int main() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
int T, A, B;
cin >> T;
for(int tc=1; tc<=T; tc++) {
cin >> A >> B;
        cout << A+B << '\n';
}
}
</syntaxhighlight>


==Java==
==Java==
<source lang='Java'>
<syntaxhighlight lang='Java'>
import java.util.*;
import java.util.*;
import java.io.*;
import java.io.*;
37번째 줄: 67번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>
<source lang='java'>
<syntaxhighlight lang='java'>
import java.io.*;
import java.io.*;
public class Main {
public class Main {
54번째 줄: 84번째 줄:
             sb.append( String.valueOf(a+b) + "\n" );
             sb.append( String.valueOf(a+b) + "\n" );
         }
         }
         System.out.print( sb.toString() );
         System.out.print( sb );
     }
     }
}
}
</source>
</syntaxhighlight>


==Perl==
==Perl==
<source lang='perl'>
<syntaxhighlight lang='perl'>
for (1 .. <>) {
for (1 .. <>) {
     ($a, $b) = (split / /, <>);
     ($a, $b) = (split / /, <>);
     printf("%d\n", $a + $b);
     printf("%d\n", $a + $b);
}
}
</source>
</syntaxhighlight>


==PHP==
==PHP==
<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php
fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%d",$N);
77번째 줄: 107번째 줄:
}
}
ob_flush();
ob_flush();
</source>
</syntaxhighlight>


==Python==
==Python==
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(sys.stdin.readline())
n = int(sys.stdin.readline())
86번째 줄: 116번째 줄:
     a,b = map(int,sys.stdin.readline().split())
     a,b = map(int,sys.stdin.readline().split())
     print( a+b )
     print( a+b )
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(sys.stdin.readline())
n = int(sys.stdin.readline())
93번째 줄: 123번째 줄:
     arr = sys.stdin.readline().split()
     arr = sys.stdin.readline().split()
     print( int(arr[0])+int(arr[1]) )
     print( int(arr[0])+int(arr[1]) )
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(input())
n = int(input())
100번째 줄: 130번째 줄:
     a, b = map(int,sys.stdin.readline().split())
     a, b = map(int,sys.stdin.readline().split())
     print( a+b )
     print( a+b )
</source>
</syntaxhighlight>
 
==참고==
* https://www.acmicpc.net/board/view/22716

2023년 8월 24일 (목) 02:14 기준 최신판

1 개요[ | ]

BOJ 15552 빠른 A+B

2 C[ | ]

#include <stdio.h>
int main() {
	int T;
	scanf("%d", &T);
	int A, B;
	for(int tc=1; tc<=T; tc++) {
		scanf("%d %d", &A, &B);
		printf("%d\n", A+B);
	}
}

3 C++[ | ]

#include <iostream>
using namespace std;
int main() {
	int T;
	scanf("%d", &T);
	int A, B;
	for(int tc=1; tc<=T; tc++) {
		scanf("%d %d", &A, &B);
		printf("%d\n", A+B);
	}
}
#include <iostream>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int T, A, B;
	cin >> T;
	for(int tc=1; tc<=T; tc++) {
		cin >> A >> B;
        cout << A+B << '\n';
	}
}

4 Java[ | ]

import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        BufferedWriter bw = new BufferedWriter( new OutputStreamWriter( System.out ) );
        int n = Integer.parseInt(br.readLine());
        String line;
        int a, b;
        for(int i=0; i<n; i++) {
            line = br.readLine();
            String[] nums = line.split(" ");
            a = Integer.parseInt(nums[0]);
            b = Integer.parseInt(nums[1]);
            bw.write( String.valueOf(a+b) + "\n" );
        }
        bw.flush();
    }
}
import java.io.*;
public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(br.readLine());
        String line;
        int a, b;
        for(int i=0; i<n; i++) {
            line = br.readLine();
            String[] nums = line.split(" ");
            a = Integer.parseInt(nums[0]);
            b = Integer.parseInt(nums[1]);
            sb.append( String.valueOf(a+b) + "\n" );
        }
        System.out.print( sb );
    }
}

5 Perl[ | ]

for (1 .. <>) {
    ($a, $b) = (split / /, <>);
    printf("%d\n", $a + $b);
}

6 PHP[ | ]

<?php
fscanf(STDIN,"%d",$N);
ob_start();
for( $i=0; $i<$N; $i++ ) {
    fscanf(STDIN,"%d %d",$a,$b);
    echo ($a+$b) . "\n";
}
ob_flush();

7 Python[ | ]

import sys
n = int(sys.stdin.readline())
for i in range(n):
    a,b = map(int,sys.stdin.readline().split())
    print( a+b )
import sys
n = int(sys.stdin.readline())
for i in range(n):
    arr = sys.stdin.readline().split()
    print( int(arr[0])+int(arr[1]) )
import sys
n = int(input())
for i in range(n):
    a, b = map(int,sys.stdin.readline().split())
    print( a+b )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}