Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <cstdlib>
- #include <fstream>
- #include <cctype>
- #include <cassert>
- using namespace std;
- // peregruz ---------
- float F_5(float a, float b, float x)
- {
- int cond = x * (x - 5);
- if(cond < 0) return a + b;
- if(cond < 10) return a - b;
- return a * b;
- }
- void F_5(float a, float b, float x, float &res)
- {
- res = F_5(a, b, x);
- }
- // shablon ----------
- template<class T> void func_2(T** ar, int w, int h, T v)
- {
- for(int x = 0; x < w; x++)
- {
- for(int y = 0; y < h; y++)
- {
- if(ar[x][y] < v)
- {
- ar[x][y] = v;
- }
- }
- }
- }
- int main()
- {
- //ifstream in("input.txt"); ofstream out("output.txt");
- cout << F_5(2, -0.5, 1) << "\n";
- cout << F_5(2, -0.5, -0) << "\n";
- cout << F_5(2, -0.5, -2) << "\n";
- cout << "--------------------\n";
- int w, h;
- w = h = 5;
- int** i_ar = new int*[w];
- for(int x = 0; x < w; x++)
- {
- i_ar[x] = new int[h];
- for(int y = 0; y < h; y++)
- {
- i_ar[x][y] = x + y;
- }
- }
- for(int y = 0; y < h; y++)
- {
- for(int x = 0; x < w; x++)
- {
- cout << i_ar[x][y] << " ";
- }
- cout << "\n";
- }
- cout << "--------------------\n";
- func_2(i_ar, w, h, 3);
- for(int y = 0; y < h; y++)
- {
- for(int x = 0; x < w; x++)
- {
- cout << i_ar[x][y] << " ";
- }
- cout << "\n";
- }
- cout << "--------------------\n";
- double** d_ar = new double*[w];
- for(int x = 0; x < w; x++)
- {
- d_ar[x] = new double[h];
- for(int y = 0; y < h; y++)
- {
- d_ar[x][y] = x + y + 0.5;
- }
- }
- for(int y = 0; y < h; y++)
- {
- for(int x = 0; x < w; x++)
- {
- cout << d_ar[x][y] << " ";
- }
- cout << "\n";
- }
- cout << "--------------------\n";
- func_2(d_ar, w, h, 3.5);
- for(int y = 0; y < h; y++)
- {
- for(int x = 0; x < w; x++)
- {
- cout << d_ar[x][y] << " ";
- }
- cout << "\n";
- }
- cout << "--------------------\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement