Đề bài tập mẫu:
Cách viết bằng C++:
Cách viết bằng C#:
Cách viết bằng Pascal:
Cách viết bằng Python 2:
Cách viết bằng Python 3:
LƯU Ý CÁCH VIẾT CHƯƠNG TRÌNH BẰNG JAVA:
Chương trình PHẢI có chứa class Main xem ví dụ để hiểu rõ hơn
import java.io.IOException;
import java.util.*;
class Main{
public static void main(String agrv[]) throws IOException{
int a,b;
Scanner inp = new Scanner(System.in);
a = inp.nextInt();
b = inp.nextInt();
System.out.printf("%d", a+b);
inp.close();
}
}
Nhập vào 2 số nguyên a và b.Click xem và làm bài tập nộp thử
yêu cầu xuất ra tổng của 2 số a và b
Cách viết bằng C++:
#include <iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
Cách viết bằng C#:
using System;
class HelloWorld {
static void Main() {
string[] str = Console.ReadLine().Split();int a = int.Parse(str[0]);int b = int.Parse(str[1]);Console.WriteLine(a+b);
}
}
Cách viết bằng Pascal:
Program TinhTong;
var a,b:integer;
begin
readln(a,b);
writeln(a+b);
end.
Cách viết bằng Python 2:
line = raw_input().split()
a=int(line[0])
b=int(line[1])
print (a+b)
Cách viết bằng Python 3:
line = input().split()
a=int(line[0])
b=int(line[1])
print (a+b)
LƯU Ý CÁCH VIẾT CHƯƠNG TRÌNH BẰNG JAVA:
Chương trình PHẢI có chứa class Main xem ví dụ để hiểu rõ hơn
import java.io.IOException;
import java.util.*;
class Main{
public static void main(String agrv[]) throws IOException{
int a,b;
Scanner inp = new Scanner(System.in);
a = inp.nextInt();
b = inp.nextInt();
System.out.printf("%d", a+b);
inp.close();
}
}