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.
uses crt;
var a:array[1..200]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
write('Vi tri la: ');
for i:=1 to n do
if max=a[i] then write(i:4);
readln;
end.
program nhap_tinhtong;
uses crt;
type kmang=array[1..1000] of integer;
var A:kmang;
n:integer;
{---Nhap---}
procedure nhap;
var i:integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
end;
end;
{---Tinh-tong---}
function tinh_tong(A:kmang; n:integer):integer;
var t,i:integer;
begin
t:=0;
for i:=1 to n do
t:=t+A[i];
tinh_tong:=t;
end;
{---CT-chinh---}
BEGIN
clrscr;
nhap;
write('Tong cac phan tu la: ',tinh_tong(A,n));
readln;
end.
program nhap_tinhtong;
uses crt;
type kmang=array[1..1000] of integer;
var A:kmang;
n:integer;
{---Nhap---}
procedure nhap;
var i:integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
end;
end;
{---Tinh-tong---}
function tinh_tong(A:kmang; n:integer):integer;
var t,i:integer;
begin
t:=0;
for i:=1 to n do
t:=t+A[i];
tinh_tong:=t;
end;
{---CT-chinh---}
BEGIN
clrscr;
nhap;
write('Tong cac phan tu la: ',tinh_tong(A,n));
readln;
end.
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[50],x,n,uc,i;
//chuongtrinhcon
unsigned long long ucln(long long a,long long b)
{
if (b==0) return(a);
else return(ucln(b,a%b));
}
//chuongtrinhchinh
int main()
{
freopen("ucln.inp","r",stdin);
freopen("ucln.out","w",stdout);
cin>>n;
cin>>a[1]>>a[2];
uc=ucln(a[1],a[2]);
for (i=3; i<=n; i++)
{
cin>>x;
uc=ucln(uc,x);
}
cout<<uc;
return 0;
}
#include <iostream>
#include <fstream>
using namespace std;
ifstream input("D:/input.txt");
ofstream output("D:/ouput.txt");
int main()
{
int A[1000];
int n ,dem=0;
input >> n;
for(int i=0;i<n;i++)
input >> A[i];
for(int i=0;i<n;i++)
if(A[i]<0)
dem +=A[i];
output << dem;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i]<0 then t:=t+a[i];
writeln('Tong cac so nguyen am la: ',t);
readln;
end.
uses crt;
const fi='vtmin.out';
var a:array[1..100]of integer;
i,n,min:integer;
f1:text;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
assign(f1,fi); rewrite(f1);
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
for i:=1 to n do
if min=a[i] then write(f1,i:4);
close(f1);
readln;
end.
uses crt;
var i,n,c,b,uc:integer;
bcnn:int64;
a:array[1..100] of integer;
{--------------------------chuong-trinh-con-tim-ucln-cua-hai-so---------------}
function ucln(c,b:integer):integer;
var r:integer;
begin
r:=c mod b;
while r<>0 do
begin
c:=b;
b:=r;
r:=c mod b;
end;
ucln:=b;
end;
{---------------------------chuong-trinh-chinh-----------------------------------}
begin
clrscr;
Write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
uc:=ucln(a[1],a[2]);
for i:=3 to n do
uc:=ucln(uc,a[i]);
writeln(uc);
readln;
end.