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..50]of int64;
i,n,t,max,min:int64;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
max:=a[1];
min:=a[1];
t:=0;
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
t:=t+a[i];
end;
writeln('Tong la: ',t);
writeln('So lon nhat la: ',max);
write('Vi tri la: ');
for i:=1 to n do
if a[i]=max then write(i:4);
writeln;
writeln('So nho nhat la: ',min);
write('Vi tri la: ');
for i:=1 to n do
if a[i]=min then write(i:4);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[100],n,i,ln,nn,vt1,vt2;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
ln=a[1];
nn=a[1];
for (i=1; i<=n; i++)
{
ln=max(ln,a[i]);
nn=min(nn,a[i]);
}
cout<<ln<<" "<<nn;
return 0;
}
Var n,i,vtl,vtn,so max,min:integer;
Begin
Write('Nhap so luong so = ');readln(n);
vtl:=0;
vtn:=0;
max:=-32768;
min:=32767;
For i:=1 to n do
Begin
Write('Nhap vao so thu ',i);readln(so);
If so > max then
Begin
Max:=so;
vtl:=i;
End;
If so < min then
Begin
Min:=so;
vtn:=i;
End;
Writeln('So lon nhat la ',max,' tai vi tri thu ',i);
Write('So nho nhat la ',min,' tai vi tri thu ',i);
Readln;
End.
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
int n;
std::cout << "Enter the number of integers (n < 10^5): ";
std::cin >> n;
std::vector<int> numbers(n); std::cout << "Enter " << n << " integers: "; for (int i = 0; i < n; ++i) { std::cin >> numbers[i]; } int sumOfOdd = 0; for (int i = 0; i < n; ++i) { if (numbers[i] % 2 != 0) { sumOfOdd += numbers[i]; } } std::sort(numbers.begin(), numbers.end()); std::cout << "Sum of odd integers: " << sumOfOdd << std::endl; std::cout << "Sorted sequence: "; for (int i = 0; i < n; ++i) { std::cout << numbers[i] << " "; } std::cout << std::endl; return 0;
}
```
câu 1
Program Nguyen_to;
Var n,i:integer;
Function NT(n:integer):Boolean;
Var ok: Boolean;
i: integer;
Begin ok:=true;
for i:=2 to n-1 do if (n mod i)= 0 then ok:=ok and false;
if n < 2 then NT:=false else NT:=ok;
End;
Begin Write('Nhap n: ');
Readln(n); i:=n;
Repeat i:=i+1;
Until NT(i);
Write('So nguyen to nho nhat lon hon ',n, 'la: ',i);
Readln End.
câu 2
uses crt;
const so: set of char=['0','1','2','3','4','5','6','7','8','9'];
var a:array[1..100] of integer;
st,b:string;
c,l,i,n,j:integer;
s, Max: integer;
begin clrscr;
write('Nhap xau:');
readln(st);
l:=length(st);
i:=1;
n:=0;
repeat if (st[i] in so) then begin b:='';
repeat b:=b+st[i];
inc(i);
until (not(st[i] in so)) or (i>l);
inc(n);
val(b,a[n],c);
end;
inc(i);
until i>l;
Max:=a[1];
for i:=2 to n do If Max<A[i] Then Max:=A[i];
Writeln('Phan tu lon nhat cua mang:', Max);
readln;
end.
uses crt;
var a:array[1..100]of integer;
k,n,i,tam,x,t:integer;
begin
clrscr;
write('nhap so ban hoc sinh:'); readln(n);
for i:=1 to n do
begin
write('ma so thu ',i,' la:'); readln(a[i]);
end;
{----------------------sap-day-tang-dan--------------------}
for i:=1 to n-1 do
for k:=i+1 to n do
if a[i]>a[k] then begin
t:=a[i];
a[i]:=a[k];
a[k]:=t;
end;
{-----------------------xu-ly-chen--------------------------}
write('nhap ma so k:'); readln(k);
i:=1;
while(k>a[i]) and (i<=n) do
i:=i+1;
for x:=n+1 downto i do
a[x]:=a[x-1];
a[i]:=k;
writeln('ket qua la:');
for i:=1 to n+1 do write(a[i],' ');
readln;
end.