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.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include<bits/stdc++.h>
using namespace std;
int findSecondLargest(int arr[], int n) {
sort(arr, arr + n, greater<int>());
return arr[1];
}
int main() {
int arr[] = {10, 20, 30, 40, 50};
int n = sizeof(arr) / sizeof(arr[0]);
int secondLargest = findSecondLargest(arr, n);
cout << "So lon thu hai trong mang la: " << secondLargest << endl;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
if(n <= 1) return false;
for(int i = 2; i <= sqrt(n); i++) {
if(n % i == 0) return false;
}
return true;
}
void printPrimes(int arr[], int n) {
for(int i = 0; i < n; i++) {
if(isPrime(arr[i])) {
cout << arr[i] << " la so nguyen to" << endl;
}
}
}
int main() {
int arr[] = {2, 3, 4, 5, 6, 7, 8, 9, 10};
int n = sizeof(arr) / sizeof(arr[0]);
printPrimes(arr, n);
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include<bits/stdc++.h>
using namespace std;
void sortAscending(int arr[], int n) {
sort(arr, arr + n);
}
int main() {
int arr[] = {10, 5, 8, 7, 6};
int n = sizeof(arr) / sizeof(arr[0]);
sortAscending(arr, n);
for(int i = 0; i < n; i++) {
cout << arr[i] << " ";
}
cout << endl;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include<bits/stdc++.h>
using namespace std;
void distinctElements(int arr[], int n) {
int i, j, count = 1;
sort(arr, arr + n);
for(i = 0; i < n - 1; i++) {
if (arr[i] != arr[i + 1]) {
count++;
out << arr[i] << " ";
}
}
cout << arr[n - 1] << " ";
cout << "\nSo phan tu khac nhau cua mang la: " << count << endl;
}
int main() {
int arr[] = {1, 2, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, 9, 9};
int n = sizeof(arr) / sizeof(arr[0]);
distinctElements(arr, n);
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include<bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int sum = 0;
for (int i = 1; i <= N; i++) {
if (sqrt(i) == (int)sqrt(i)) {
sum += i;
}
}
cout << sum << endl;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
#include <cmath>
int main() {
double x = 16.0;
double squareRoot = sqrt(x);
std::cout << "Căn bậc hai của " << x << " là: " << squareRoot << std::endl;
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
#include <bits/stdc++.h>
int main() {
int n;
cin>>n;
int sum=0;
for(int i=1;i<=n;i++)
{
sum+=i*i;
}
cout<<"The total is: "<<sum<<endl;
for(int j=0;j<=50000;j++)
{
int du=j%10;
int tongcacso=j%10*j%10*j%10;
cout<<"du="<<du<<endl;
sum=sum+du*du*du;
cout<<"\nsum= "<<sum<<endl;
cout<<"sum= (sum+j*j*j) "<<endl;
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int sumOfOddElements(int arr[], int n) {
int sum = 0;
for(int i = 0; i < n; i++) {
if(arr[i] % 2 != 0) {
sum += arr[i];
}
}
return sum;
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
int n = sizeof(arr) / sizeof(arr[0]);
int sumOfOdd = sumOfOddElements(arr, n);
cout << "Tong cac phan tu le cua mang la: " << sumOfOdd << endl;
return 0;
}