Bạn chưa đăng nhập. Vui lòng đăng nhập để hỏi bài

Những câu hỏi liên quan
Hello1234
Xem chi tiết
Hello1234
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 10 2021 lúc 15:00

#include <bits/stdc++.h>

using namespace std;

int main()

{

long a[105], i,n,max,vt;

cout<<"n="; cin>>n;

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

{

cout<<"A["<<i<<"]="; cin>>a[i];

}

max=a[1];

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

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

vt=1;

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

if (max==a[i]) vt=i;

cout<<max<<endl;

cout<<vt;

return 0;

}

 

26-Do Thanh Trung
Xem chi tiết
Hello1234
Xem chi tiết
Nguyễn Lê Phước Thịnh
2 tháng 10 2021 lúc 0:25

#include <bits/stdc++.h>;
using namespace std;
int main()
{
    long i,n;
    float tbc,dem,t,a[10000];
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    dem=0;
    t=0;
    for (i=1; i<=n; i++)
        if (a[i]<0)
    {
        dem=dem+1;
        t=t+a[i];
    }
    tbc=t/dem;
    cout<<fixed<< setprecision(2)<<tbc;
    return 0;
}

 

huynh chinh
Xem chi tiết
huynh chinh
5 tháng 1 2023 lúc 18:42

PASCAL giups mik

 

phạm lê minh sơn
Xem chi tiết
Trần Trung Hiếu THCS Thá...
Xem chi tiết

#include <iostream>
#include <vector>

using namespace std;

vector<int> primeFactors(int n) {
    vector<int> factors;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            factors.push_back(i);
            n /= i;
        }
    }
    if (n > 1) factors.push_back(n);
    return factors;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> factors = primeFactors(k);
    int sum = accumulate(a.begin(), a.end(), 0);
    vector<vector<bool>> dp(n+1, vector<bool>(sum+1, false));
    dp[0][0] = true;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= sum; ++j) {
            dp[i][j] = dp[i-1][j];
            if (j >= a[i-1]) {
                for (int factor : factors) {
                    if (a[i-1] % factor == 0) {
                        dp[i][j] = dp[i][j] || dp[i-1][j-a[i-1]];
                        break;
                    }
                }
            }
        }
    }

    for (int j = 0; j <= sum; ++j) {
        if (dp[n][j]) {
            cout << j << endl;
            break;
        }
    }

    return 0;
}

nguyentienlam
Xem chi tiết
nguyentienlam
4 tháng 4 2023 lúc 15:21

cứu m vs

 

Võ Thị Thanh Trúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
3 tháng 3 2021 lúc 13:30

uses crt;

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

n,i,t,max,min: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] mod 3=0 then t:=t+a[i];

writeln('Tong cac so la boi cua 3 la: ',t);

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('Gia tri lon nhat la: ',max);

writeln('Gia tri nho nhat la: ',min);

readln;

end.