Для хранения изображения размером 512х128 пикселя отвели 32 Кбайт памяти. Найти количество информации для хранения одного пикселя? С условием и решением
#include <iostream> #include <cstdlib> #include <ctime> int main() { using namespace std; cout << "Enter size of array: "; int N; cin >> N; int * ARR = new int[N]; srand(time(0)); int i; for (i = 0; i < N; ++i) ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
int temp = ARR[N - 1]; for (i = N - 1; i > 0; --i) ARR[i] = ARR[i - 1]; ARR[0] = temp;
cout << "\nHere is a new array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
#include <cstring>
#include <vector>
#include <algorithm>
struct StudentData
{
std::string name;
std::string surname;
int math;
int phys;
int comp_science;
};
bool
comp(const StudentData &a, const StudentData &b)
{
int tmp1 = a.math + a.phys + a.comp_science;
int tmp2 = b.math + b.phys + b.comp_science;
return tmp1 > tmp2 ? true : false;
}
int
main(void)
{
int n;
std::cin >> n;
std::vector< StudentData > data(n);
for (int i = 0; i < n; i++) {
std::cin >> data[i].name >> data[i].surname;
std::cin >> data[i].math >> data[i].phys >> data[i].comp_science;
}
std::sort(data.begin(), data.end(), comp);
for (int i = 0; i < n; i++) {
std::cout << data[i].name << " " << data[i].surname << std::endl;
}
return 0;
}