Рассчитать объём памяти, необходимой для представления одноминутного фильма на экране монитора с разрешением 600*600 пикселей и палитрой из 256 цветов. *
//Я просто опишу метод записи матрицы const n=100; var ar:array of array of integer; ars:array of array of string; i:integer;
procedure complection(var ar:array of array of integer;var ars:array of array of string); var i,j:integer; begin; for i:=1 to n do begin; for j:=1 to n do begin; ar[i,j]:=random(9); str(ar[i,j],ars[i,j]); end; end; end;
procedure burning(ars:array of array of string); var i,j:integer; t:text; begin; assign(t,'text.txt'); rewrite(t); for i:=1 to n do begin; writeln(t,' '); for j:=1 to n do write(t,ars[i,j],' '); end; end;
begin; randomize; setlength(ar,n+1); setlength(ars,n+1); for i:=1 to n do begin; setlength(ar[i],n+1); setlength(ars[i],n+1); end; complection(ar,ars); burning(ars); end.
Код:
#include <fstream>#include <cmath>void first_task(std::ifstream &cin, std::ofstream &cout) { int n, k = 1; cin >> n >> k; cout << n / k;}void second_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; cout << 2 * (N / 2 + 1);}void third_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; auto t = [](int c, int N){return c / (int) pow(10, N) % 10;}; cout << t(N, 2) + t(N, 1) + t(N, 0);}void fourth_task(std::ifstream &cin, std::ofstream &cout) { int N; cin >> N; for (int it = 0; it < log2(N); ++it) { cout << pow(2, it) << " "; }}void fifth_task(std::ifstream &cin, std::ofstream &cout) { int h, a, b; cin >> h >> a >> b; int h0 = h - a, dx = a - b; int g = 1 + h0/dx + (h0%dx + dx - 1)/dx; if (g < 0) cout << INFINITY; else cout << g;}int main() { std::ifstream cin("input.txt"); std::ofstream cout("output.txt"); // Choose your function int N = 0; // 0-4 void (*tasks[5]) (std::ifstream &, std::ofstream &) = {first_task, second_task, third_task, fourth_task, fifth_task}; tasks[N](cin, cout); return 0;}