Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
Bài 1
Var s,i:integer;
tb:real;
Begin
Write('Nhap n = ');readln(n);
i:=1;
s:=0;
While i<=n do
Begin
s:=s+i;
i:=i+1;
End;
tb:=s/n;
Writeln('Tong la ',s);
Write('Trung binh la ',tb:10:2);
Readln;
End.
Bài 2
Var i,n,souoc:integer;
Begin
Write('Nhap n = ');readln(n);
i:=1;
While i <= n do
Begin
i:=i + 1;
If n mod i = 0 then souoc:=souoc + 1;
End;
If souoc = 1 then write(n,' la so nguyen to')
Else write(n,' khong la so nguyen to');
Readln;
End.
Bài 2:
#include <bits/stdc++.h>
using namespace std;
long long x,y;
int main()
{
cin >>x>>y;
cout<<x<<" "<<y;
swap(x,y);
cout<<x<<" "<<y;
return 0;
}
Program HOC24;
var i,n: byte;
t: longint;
a: array[1..100] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i]>10 then t:=t+a[i];
writeln('Tong cac so lon hon 10 la: ',t);
readln
end.
Program HOC24;
var a: array[1..32000] of integer;
i,n,d: integer;
begin
write('Nhap N: ');
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Day vua nhap la: ');
for i:=1 to n do write(a[i],' '); writeln;
d:=0;
for i:=1 to n do if a[i]>0 then d:=d+1;
write('Co ',d,' so duong');
readln
end.
program TongChuSo;
var
n, sum: integer;
begin
write('Nhap n: ');
readln(n);
sum := 0;
while n > 0 do
begin
sum := sum + (n mod 10);
n := n div 10;
end;
writeln('Tong cac chu so cua n la: ', sum);
readln;
end.
program TongN;
var
n, i, Tong: integer;
begin
writeln('Nhap so nguyen n:');
readln(n);
while(n<5) or (n>15) do
begin
writeln('Vui long nhap n nam trong khoang 5-15');
readln(n);
end;
Tong := 0;
for i:=1 to n do
Tong := Tong + i;
writeln('Tong cac so tu 1 den n: ', Tong);
readln;
end.
Uses crt;
var i,n,x: integer;
begin clrscr;
readln(n);
for i:=1 to n do x:=x*i;
writeln(x);
readln;
end.
Program HOC24;
var i,n: integer;
s: longint;
begin
write('Nhap n: '); readln(n);
s:=1;
for i:=1 to n do s:=s*i;
write(n,'! = ',s);
readln
end.