K
Khách

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.

14 tháng 3 2023

Program HOC24;

var i,n,max: integer;

a: array[1..1000] of integer;

begin

write('Nhap n: '); readln(n);

i:=1; max:=-1;

while i<=n do

begin

write('Nhap so thu ',i,': '); readln(a[i]);

if a[i]>max then max:=a[i];

i:=i+1;

end;

write('So lon nhat la: ',max);

readln

end.

13 tháng 7 2021
Code:#include <stdio.h> struct phanso {int tu;int mau;}; int ucln(int a, int b) {while(a!=b){if(a>b)a=a-b;elseb=b-a;}return a;} struct phanso tg(struct phanso a) {int c = ucln(a.tu, a.mau);a.tu /= c;a.mau /= c;return a;} struct phanso tong(struct phanso a, struct phanso b) {struct phanso s;s.tu = (a.tu * b.mau) + (b.tu * a.mau);s.mau = a.mau * b.mau;return s;} main() {struct phanso ps[100];struct phanso s;int n, x = 0, maxnum;double gtps[100], max;unsigned int i;printf("Nhap n: "); scanf("%d", &n);for (i = 0; i < n; i++) {printf("Nhap tu so cua phan so so %d: ", i + 1); scanf("%d", &ps[i].tu);printf("Nhap mau so cua phan so so %d: ", i + 1); scanf("%d", &ps[i].mau);}s = ps[0];for (i = 1; i < n; i++) {s = tong(s, ps[i]);}printf("\n");printf("a) Tong: %d/%d\n", tg(s).tu, tg(s).mau);for (i = 0; i < n; i++) {if (ps[i].mau != tg(ps[i]).mau) {x += 1;}}printf("b) So phan so chua toi gian: %d\n", x);for (i = 0; i < n; i++) {gtps[i] = (double)ps[i].tu / (double)ps[i].mau;}max = gtps[0];for (i = 1; i < n; i++) {if (max < gtps[i]) {maxnum = i;max = gtps[i];}}printf("c) Phan so co gia tri lon nhat la: %d/%d", ps[maxnum].tu, ps[maxnum].mau);return 0;} Ảnh:
27 tháng 5 2022

var a:[array] of integer;

i,n,max,min,s:integer;

begin

write('Nhap so luong so n = ');readln(n);

for i:=1 to n do

begin

write('Nhap so thu ',i,' = ');readln(a[i]);

end;

max:=a[1];

min:=a[1];

s:=0;

for i:=1 to n do

begin

if a[i] > max then max:=a[i];

if a[i] < min then min:=a[i];

s:=s+a[i];

end;

writeln('So lon nhat la ',max);

writeln('So nho nhat la ',min);

writeln('Tong cac phan tu trong day la ',s);

writeln('Cac so chia het cho 2 la: ');

for i:=1 to n do

if a[i] mod 2 = 0 then write(a[i],'      ');

readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long a[100],i,n,t,nn;

int main()

{

cin>>n;

for (i=1;i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

cout<<a[i]<<" ";

cout<<endl;

t=0;

for (i=1; i<=n; i++) if (a[i]%2==0) t+=a[i];

nn=a[1];

for (i=1; i<=n; i++)

nn=min(nn,a[i]);

cout<<t<<endl;

cout<<nn<<endl;

cout<<a[1]+a[n];

return 0;

}

2: 

uses crt;

var a:array[1..100]of integer;

n,i:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

begin

write('A[',i,']='); readln(a[i]);

end;

for i:=1 to n do 

  if a[i]<0 then write(i:4);

readln;

end.

17 tháng 3 2021

câu 3 nữa bạn, mình ko hiểu đc câu đó

 

28 tháng 4 2023

var a:array[1..1000] of integer;

i,n,min:integer;

s:longint;

begin

write('n = ');readln(n);

for i:=1 to n do

begin

write('Nhap so thu ',i,' = ');readln(a[i]);

s:=s+a[i];

end;

writeln('Tong la ',s);

min:=a[1];

for i:=2 to n do

if a[i] < min then min:=a[i];

write('Cac so chan la ');

for i:=1 to n do

if a[i] mod 2 = 0 then write(a[i]:8);

writeln;

write('so nho nhat la ',min);

readln

end.

10 tháng 4 2023

Uses crt;

var max,min,n,i,m,n: longint;

a: array[1..100] of longint

begin clrscr;

for i:=1 to n do begin

if(a[i] mod 2=0) then m:=m+a[i];

if(a[i] mod 2<>0) then n:=n+a[i];

end;

max:=a[1];

min:=a[1];

for i:=1 to n do begin

if(max<a[i]) then max:=a[i];

if(min>a[i]) then min:=a[i];

end;

Writeln('Tong cac phan tu chan: ',m);

Writeln('Tong cac phan tu le: ',n);

Writeln('Phan tu co gia tri lon nhat: ',max);

Writeln('Phan tu co gia tri nho nhat: ',min);

readln;

end.

11 tháng 4 2023

Uses crt;

var max,min,n,i,m,n: longint;

a: array[1..100] of longint

begin clrscr;

for i:=1 to n do begin

if(a[i] mod 2=0) then m:=m+a[i];

if(a[i] mod 2<>0) then n:=n+a[i];

end;

max:=a[1];

min:=a[1];

for i:=1 to n do begin

if(max<a[i]) then max:=a[i];

if(min>a[i]) then min:=a[i];

end;

Writeln('Tong cac phan tu chan: ',m);

Writeln('Tong cac phan tu le: ',n);

Writeln('Phan tu co gia tri lon nhat: ',max);

Writeln('Phan tu co gia tri nho nhat: ',min);

readln;

end.