информатикой на узб яз 3. Axborot xavfsizligi va “elektron jinoyatchilik”lardan himoyalanishni ta’minlovchi chora-tadbirlar to‘g‘risida ma’lumot bering.
2. 28800 bit/s tezlikda ishlovchi modem ikkita sahifadan 3600 bayt iborat matnni qancha vaqtda uzatadi?
2. Agar ekran sohasi 512x128 nuqtali va har bir nuqta 256 rangdan biriga ega bo‘lsa, bu sohani saqlash uchun kerak bo‘ladigan eng kam xotira hajmi (Kb)ni belgilang.
#include <vector>
#include<iostream>
template <typename T>
inline void swap(T& arg1, T& arg2)
{
T temp = arg1;
arg1 = arg2;
arg2 = temp;
};
template <typename T>
inline void merge(std::vector<T>& vArray, std::vector<T>& vTemp, int head, int middle, int tail)
{
int tmp = 0, lower = head, upper = middle + 1;
while (lower <= middle && upper <= tail)
{
if (vArray[lower] < vArray[upper])
{
vTemp[tmp++] = vArray[lower++];
}
else
{
vTemp[tmp++] = vArray[upper++];
}
}
if (lower <= middle)
{
for (; lower <= middle; vTemp[tmp++] = vArray[lower++]);
}
else
{
for (; upper <= tail; vTemp[tmp++] = vArray[upper++]);
}
int arrayPointer = head;
for (tmp = 0; arrayPointer <= tail; vArray[arrayPointer++] = vTemp[tmp++]);
}
template <typename T>
inline void merge_sort_helper(std::vector<T>& vArray, std::vector<T>& vTemp, int head, int tail)
{
if (head == tail)
{
return;
}
int middle = (head + tail) / 2;
merge_sort_helper(vArray, vTemp, head, middle);
merge_sort_helper(vArray, vTemp, middle + 1, tail);
merge(vArray, vTemp, head, middle, tail);
}
template <typename T>
void merge_sort(std::vector<T>& vArray)
{
std::vector<T> v(vArray.size(), 0);
merge_sort_helper(vArray, v, 0, vArray.size() - 1);
}
int main() {
int n;
std::cin >> n;
std:: vector<int>vArray(n);
for (int i = 0; i < n; i++) {
std:: cin >> vArray[i];
}
merge_sort(vArray);
for (int i = 0; i < n; i++) {
std::cout << vArray[i]<<" ";
}
}
Примерно так
#include <iostream>
#include <chrono>
#include <ctime>
int main()
{
auto start = std::chrono::system_clock::now();
auto end = std::chrono::system_clock::now();
bool Cycle = true;
double SredSum=0;
std::time_t end_time;
double Entered = 0, count = 0;
setlocale(LC_ALL, "Russian");
std::cout.precision(5);
std::chrono::duration<double> elapsed_seconds = end - start;
do {
std::cin >> Entered;
if (std::cin.fail()){
Cycle = false;
break;
}
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
SredSum = ((SredSum * count) + Entered) / (count + 1.0);
count++;
std::cout << "Среднее значение этих " << count << " чисел равно " << SredSum << std::endl;
if (elapsed_seconds.count() > 60) { Cycle = false; }
} while (Cycle);
}