Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Header.h"
- #include <iostream>
- using namespace std;
- int glob_sad = 12;
- //int glob_sad = 15;
- int sum(int a, int b, int c = 0) {
- return a + b + c;
- }
- void say_hello() {
- static int n = 0;
- switch (n) {
- case 0: cout << "Good morning" << endl; break;
- case 1: cout << "Good arternoon" << endl; break;
- case 2: cout << "Good evening" << endl; break;
- case 3: cout << "Good night" << endl; break;
- default: break;
- }
- //n = ++n % 3;
- n = n + 1;
- n = n % 4;
- }
- void task_hello() {
- char ch = 'y';
- while (ch != 'n') {
- cin >> ch;
- say_hello();
- }
- }
- /// <summary>
- /// copy_invert
- /// </summary>
- /// <param name="size"></param>
- /// <param name="arr"></param>
- /// <param name="copy_arr"></param>
- void copy_invert(int size, int* arr, int* copy_arr) {
- for (int k = 0; k < size; k++) {
- *(copy_arr + k) = *(arr + size - 1 - k);
- }
- }
- void test_copy_invert() {
- int arr[]{ 88,89,90,91,92 };
- int copy_arr[5];
- copy_invert(size(arr), arr, copy_arr);
- if (copy_arr[0] == 92 &&
- copy_arr[1] == 91 &&
- copy_arr[2] == 90 &&
- copy_arr[3] == 89 &&
- copy_arr[4] == 88) {
- cout << "OK" << endl;
- }
- else {
- cout << "BAD" << endl;
- }
- }
- void show_arr(int size, int* arr) {
- for (int k = 0; k < size; k++) {
- cout << arr[k] << " ";
- }
- cout << endl;
- }
- template <typename T>
- void my_swap(T& x, T& y) {
- T temp = x;
- x = y;
- y = temp;
- }
- void task_copy_invert() {
- int arr[]{ 1,2,4,1,4,3,5,6,2,3,4 };
- int copy[size(arr)];
- copy_invert(size(arr), arr, copy);
- show_arr(size(arr), arr);
- show_arr(size(arr), copy);
- int temp = copy[0];
- copy[0] = copy[1];
- copy[1] = temp;
- show_arr(size(arr), copy);
- }
- int main() {
- //test_copy_invert();
- //task_copy_invert();
- int x = 3, y = 4;
- cout << "x: " << x << " y: " << y << endl;
- my_swap(x, y);
- cout << "x: " << x << " y: " << y << endl;
- double w = 55.6, v = 23.12;
- cout << "w: " << w << " v: " << v << endl;
- my_swap(w, v);
- cout << "w: " << w << " v: " << v << endl;
- char ch1 = 'f', ch2 = 'a';
- cout << "ch1: " << ch1 << " ch2: " << ch2 << endl;
- my_swap(ch1, ch2);
- cout << "ch1: " << ch1 << " ch2: " << ch2 << endl;
- //task_hello();
- /*
- cout << glob_sad << endl;
- glob_sad++;
- glob_sad = glob_sad;
- cout << sum(1, 2, 3) << endl;
- cout << sum(1, 2) << endl;
- cout << sum(1, 2, 0) << endl;
- my_fun();
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment