Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- const int sz1 = 5;
- const int sz2 = 6;
- void genArray(int arr[sz1][sz2],
- const int min,
- const int max) {
- for (int k = 0; k < sz1; ++k) {
- for (int n = 0; n < sz2; ++n) {
- arr[k][n] = min + rand() % (max - min + 1);
- }
- }
- }
- void showArr(const int arr[sz1][sz2]){
- for (int k = 0; k < sz1; ++k) {
- for (int n = 0; n < sz2; ++n) {
- cout << arr[k][n] << "\t";
- }
- cout << endl;
- }
- int buff[sz1 + 1][sz2 + 1]{};
- for (int k = 0; k < sz1; ++k) {
- for (int n = 0; n < sz2; ++n) {
- buff[k][n] = arr[k][n];
- buff[k][sz2] += arr[k][n];
- buff[sz1][n] += arr[k][n];
- //buff[sz1][sz2] += buff[sz1][n];
- }
- buff[sz1][sz2] += buff[k][sz2];
- }
- cout << endl;
- for (int k = 0; k < sz1+1; ++k) {
- for (int n = 0; n < sz2+1; ++n) {
- if (n == sz2)
- cout << "|\t";
- cout << buff[k][n] << "\t";
- }
- cout << endl;
- if (k == sz1-1)
- cout << "---------------------------------------------------------\n";
- }
- }
- double qube(const double x) {
- return x * x * x;
- }
- int search(const int arr[], const int arr2[], const int sz1, const int sz2) {
- bool flag;
- for (int k = 0; k < sz1-sz2;k++) {
- if (arr[k] == arr2[0]) {
- flag = true;
- for (int n = 1; n < sz2; n++) {
- if (arr[k + n] != arr2[n]) {
- flag = false;
- break;
- } //return -1;
- }
- if(flag)
- return k;
- }
- }
- return -1;
- }
- void solve_task2() {
- const int sz1 = 9;
- int arr[]{1, 2, 3, 5, 5, 6, 3, 4, 9};
- const int sz2 = 2;
- int arr2[]{ 3, 4 };
- cout << "pos: " << search(arr, arr2, sz1, sz2) << endl;
- }
- void solve_task1() {
- int arr[sz1][sz2];
- srand(time(NULL));
- genArray(arr,0, 10);
- showArr(arr);
- }
- void test_dinamicarray(int n){
- //double x[3]{ 3.141592, 0.5, 0.25};
- //cout << x << " " << &(x[0]) << " " << &(*x) << endl;
- //cout << pVal << " " << pVal[1] << endl;
- double* pVal = new double[n]; /// x
- int k = 0;
- while(k < n){
- pVal[k] = k*sqrt(2);
- k++;
- }
- //delete[] pVal;
- //double y = 2.3;
- //pVal = &y;
- for (int k = 0; k < 1; k++) {
- cout << pVal[k] << " ";
- }
- cout << endl;
- cout << "size: " << _msize(pVal) / sizeof(pVal[0]) << endl;
- //cout << endl;
- delete[] pVal;
- }
- int main(){
- //solve_task1();
- //solve_task2();
- test_dinamicarray(4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement