Editorial for Tính tổng 2 số nguyên
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Đây là bài tập mẫu giúp các bạn làm quen hệ thống, do đó mình sẽ cung cấp lời giải mẫu để các bạn tham khảo.
Lời giải Scratch
Lời giải C
#include <stdio.h>
int main(){
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a+b);
return 0;
}
Lời giải Java
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
System.out.println(a+b);
}
}
Lời giải CSharp
using System;
public class Program
{
static void Main(string[] args)
{
var numbers = Console.ReadLine();
var numberList = numbers.Split(' ');
var number1 = Convert.ToInt32(numberList[0]);
var number2 = Convert.ToInt32(numberList[1]);
Console.WriteLine(number1 + number2);
}
}
Lời giải Javascript 1
// Start of template
process.stdin.resume();
process.stdin.setEncoding('ascii');
// declare global variables
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
input_stdin += data;
});
// standard input is done and stored into an array
// then main is called so that you can start processing your data
process.stdin.on('end', function () {
input_stdin_array = input_stdin.split("\n");
main();
});
// reads a line from the standard input array
function readLine() {
return input_stdin_array[input_currentline++];
}
// End of template
// Code here
function main() {
let a = readLine().split(' ');
console.log(parseInt(a[0]) + parseInt(a[1]));
}
Lời giải Javascript 2
const readline = require('readline');
const rl = readline.createInterface({ input: process.stdin });
rl.on('line', (input) => {
const [a, b] = input.split(' ').map(Number)
console.log(a + b);
});
Lời giải Python3
a, b = [int(x) for x in input().split()]
print(a+b)
Comments
Nếu như bị lộ case test thì sẽ có nhiều trường hợp tận dụng các lỗ hổng sẵn có để tạo ra tool pass hết các bài đó bạn, chưa hiểu vì mục đích để làm gì nhưng đó sẽ ảnh hưởng không tốt tới web bạn ạ