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.
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
for (int i = 1; i <= 3; i++)
{
cin >> s;
cout << s << " ";
}
}
Câu 1:
uses crt;
var a,b:integer;
begin
clrscr;
readln(a,b);
writeln((a+b)/2:4:2);
readln;
end.
#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;
}
#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;
}
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
const int maxN = 1e4 + 1;
int n, k, arr[maxN];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for(int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
cout << arr[k - 1];
}
Input:
7 4
29 847 1928 45 298 918219 38129
Output: 847
#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;
}
#include <iostream>
using namespace std;
int main() {
string A, B;
getline(cin, A);
getline(cin, B);
int count = 0;
for (int i = 0; i <= B.length() - A.length(); i++) {
bool found = true;
for (int j = 0; j < A.length(); j++) {
if (B[i+j] != A[j]) {
found = false;
break;
}
}
if (found) {
count++;
}
}
cout << count;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
int time = (a * b) / __gcd(a, b);
cout << time;
return 0;
}