Viết chương trình nhập 2 số nguyên a và b từ bàn phím và in ra màn hình

Pascal:

uses crt;var a,b,S1,S2:longint;beginclrscr;   write['Nhap a,b: '];readln[a,b];   if a mod 2=0 then S1:=a+b;   if b mod 2=1 then S2:=a-b;   writeln['S1= ',S1];   writeln['S2= ',S2];readln

end.

C++:

#include using namespace std;int a,b,S1=0,S2=0;int main[] {   couta>>b;   if [a%2==0] S1=a+b;   if [b%2==1] S2=a-b;   cout

Bài Viết Liên Quan

Chủ Đề