Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Wykład_04.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int tmp = 10;
- void fun();
- void fun(int);
- void fun(int, double);
- void fun1(int, double = 3.14);
- void fun2(int*);
- void fun3(int&);
- void minTabVal(int*, int);
- int fun4() {
- int wrt = 6;
- return wrt;
- }
- int* fun5() {
- int wrt = 6;
- int* ptr = &wrt;
- return ptr;
- }
- int* fun5_I() {
- int* ptr = new int[10];
- return ptr;
- }
- int* minTabVal_II(int*, int);
- /*
- int dodaj(int wI1, int wI2) {
- int res = wI1 + wI2;
- return res;
- }
- double dodaj(double wD1, double wD2) {
- double res = wD1 + wD2;
- return res;
- }
- */
- template <typename T>
- T dodaj(T wD1, T wD2) {
- T res = wD1 + wD2;
- return res;
- }
- int main()
- {
- int tmp = 15;
- {
- int tmp = 18;
- cout << ::tmp << endl;
- }
- // ==================================================
- //a + b / c
- //a + b - c
- /*
- int wrt = 6;
- int* ptr = &wrt;
- cout << ++*ptr << endl;
- a + b = 5;
- a = b + 5;
- *(ptr + 2) = 5;
- */
- // ===================
- fun(18);
- fun( 20, 3.14);
- fun1(18);
- int tab[] = {10, 20, 3, 40, 10 , 2, 5};
- minTabVal(tab, 7);
- cout << "TU: " << *fun5() << endl;
- // ===============
- int w1 = 5,
- w2 = 8;
- cout << dodaj(w1, w2) << endl;
- double d1 = 3.14,
- d2 = 6.28;
- cout << dodaj(d1, d2) << endl;
- return 0;
- }
- void fun() {
- }
- void fun(int wrt) {
- cout << wrt << endl;
- }
- void fun(int wI, double wD) {
- cout << wI << " " << wD << endl;
- }
- void fun1(int wI, double wD) {
- cout << wI << " " << wD << endl;
- }
- void minTabVal(int* ptrTab, int size) {
- int currMin = *ptrTab;
- for (int i = 0; i < size; i++) {
- if (*ptrTab < currMin)
- currMin = *ptrTab;
- ptrTab++;
- }
- cout << currMin << endl;
- }
- int* minTabVal_II(int* ptrTab, int size) {
- int* currMin = ptrTab;
- for (int i = 0; i < size; i++) {
- if (*ptrTab < *currMin)
- currMin = ptrTab;
- ptrTab++;
- }
- cout << *currMin << endl;
- return currMin;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement