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.

Câu 2: 

uses crt;

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

i,n,min,dem1,dem2,t1,t2: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);

dem1:=0;

dem2:=0;

t1:=0;

t2:=0;

for i:=1 to n do 

begin

if a[i] mod 2=0 then 

begin

inc(dem1);

t1:=t1+a[i];

end

else begin

inc(dem2);

t2:=t2+a[i];

end;

end;

writeln('So so chan la: ',dem1);

writeln('So so le la: ',dem2);

writeln('Tong cac so chan la: ',t1);

writeln('Tong cac so le la: ',t2);

readln;

end.

Câu 1: 

const fi='dulieu.inp';

fo='ketqua.out';

var f1,f2:text;

m,n,t,i:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,m,n);

t:=0;

for i:=m to n do 

  if i mod 2=1 then t:=t+i;

writeln(f2,t);

close(f1);

close(f2);

end.

const fi='dulieu.inp';

fo='kq.inp';

var f1,f2:text;

a,b,c,delta:real;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b,c);

delta:=sqr(b)-4*a*c;

if delta<0 then writeln(f2,'Phuong trinh vo nghiem');

if delta=0 then writeln(f2,'Phuong trinh co nghiem kep la: ',-b/(2*a):4:2);

if delta>0 then 

begin

writeln(f2,'Nghiem thu nhat la: ',(-b+sqrt(delta))/(2*a):4:2);

writeln(f2,'Nghiem thu hai la: ',(-b-sqrt(delta))/(2*a):4:2);

end;

close(f1);

close(f2);

end. 

31 tháng 3 2021

Cảm ơn nha

Bài 3: 

uses crt;

const fi='teptong.txt';

var a,b:integer;

f1:text;

begin

clrscr;

assign(f1,fi); rewrite(f1);

readln(a,b);

writeln(a+b);

writeln(f1,a+b);

close(f1);

readln;

end.

uses crt;

const fi='so.txt';

var f1:text;

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

n,i:integer;

begin

clrscr;

assign(f1,fi); reset(f1);

readln(f1,n);

for i:=1 to n do  

  read(f1,a[i]);

for i:=1 to n do 

  write(a[i]:4);

close(f1);

readln;

end.

Bài 1: 

function canbac2(x:longint):real;

begin

canbac2:=sqrt(x);

end;

Bài 2: 

function tong(n:longint):longint;

var s,i:longint;

begin

s:=0;

for i:=1 to n do 

  s:=s+i;

tong:=s;

end;

#include <bits/stdc++.h>

using namespace std;

double a,cv,dt;

int main()

{

cin>>a;

cv=a*4;

dt=a*a;

cout<<fixed<<setprecision(2)<<cv<<endl;

cout<<fixed<<setprecision(2)<<dt;

return 0;

}

const fi='input.txt';

fo='output.txt';

var f1,f2:text;

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

i,n,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do 

begin

inc(n);

read(f1,a[n]);

end;

t:=0;

for i:=1 to n do t:=t+a[i];

write(f2,t);

close(f1);

close(f2);

end.

const fi='input.inp';

fo='output.out';

var a,b:integer;

f1,f2:text;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,a,b);

if a<b then writeln(f2,a)

else writeln(f2,b);

close(f1);

close(f2);

end.

30 tháng 3 2022

Viết giúp mik nhưng là cho biết 2 số lớn nhất với ạ

5 tháng 3 2023

#include <iostream>
using namespace std;

int main() 

{

         int N, sum = 0, num;

         float average;

         cout << "Nhap so phan tu cua day: ";

         cin >> N;

        // Vòng lặp để nhập dữ liệu cho các phần tử trong dãy

       for (int i = 0; i < N; i++) {

              cout << "Nhap phan tu thu " << i+1 << ": ";

              cin >> num;

              sum += num; // tính tổng của dãy

}

// tính trung bình cộng của dãy

average = (float) sum / N;

cout << "Trung binh cong cua day la: " << average;

return 0;

}