Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. // Wykład_04.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int tmp = 10;
  10.  
  11. void fun();
  12.  
  13. void fun(int);
  14. void fun(int, double);
  15. void fun1(int, double = 3.14);
  16.  
  17. void fun2(int*);
  18. void fun3(int&);
  19.  
  20. void minTabVal(int*, int);
  21.  
  22. int fun4() {
  23.     int wrt = 6;
  24.     return wrt;
  25. }
  26.  
  27. int* fun5() {
  28.     int wrt = 6;
  29.     int* ptr = &wrt;
  30.     return ptr;
  31. }
  32.  
  33. int* fun5_I() {
  34.     int* ptr = new int[10];
  35.     return ptr;
  36. }
  37.  
  38. int* minTabVal_II(int*, int);
  39. /*
  40. int dodaj(int wI1, int wI2) {
  41.     int res = wI1 + wI2;
  42.     return res;
  43. }
  44.  
  45. double dodaj(double wD1, double wD2) {
  46.     double res = wD1 + wD2;
  47.     return res;
  48. }
  49. */
  50.  
  51. template <typename T>
  52. T dodaj(T wD1, T wD2) {
  53.     T res = wD1 + wD2;
  54.     return res;
  55. }
  56.  
  57.  
  58. int main()
  59. {
  60.     int tmp = 15;
  61.     {
  62.         int tmp = 18;
  63.  
  64.         cout << ::tmp << endl;
  65.     }
  66.  
  67.     // ==================================================
  68.  
  69.  
  70.     //a + b / c
  71.  
  72.  
  73.     //a + b - c
  74.  
  75. /*
  76.     int wrt = 6;
  77.     int* ptr = &wrt;
  78.  
  79.  
  80.     cout << ++*ptr << endl;
  81.  
  82.  
  83.     a + b = 5;
  84.  
  85.     a = b + 5;
  86.  
  87.     *(ptr + 2) = 5;
  88. */
  89.  
  90. // ===================
  91.  
  92.     fun(18);
  93.  
  94.     fun( 20, 3.14);
  95.  
  96.     fun1(18);
  97.  
  98.     int tab[] = {10, 20, 3, 40, 10 , 2, 5};
  99.     minTabVal(tab, 7);
  100.  
  101.     cout << "TU: " << *fun5() << endl;
  102.  
  103.  
  104. // ===============
  105.  
  106.     int w1 = 5,
  107.         w2 = 8;
  108.  
  109.     cout << dodaj(w1, w2) << endl;
  110.  
  111.     double d1 = 3.14,
  112.         d2 = 6.28;
  113.  
  114.     cout << dodaj(d1, d2) << endl;
  115.  
  116.     return 0;
  117. }
  118.  
  119. void fun() {
  120.  
  121. }
  122.  
  123. void fun(int wrt) {
  124.     cout << wrt << endl;
  125. }
  126.  
  127. void fun(int wI, double wD) {
  128.     cout << wI << " " << wD << endl;
  129. }
  130. void fun1(int wI, double wD) {
  131.     cout << wI << " " << wD << endl;
  132. }
  133.  
  134. void minTabVal(int* ptrTab, int size) {
  135.     int currMin = *ptrTab;
  136.     for (int i = 0; i < size; i++) {
  137.         if (*ptrTab < currMin)
  138.             currMin = *ptrTab;
  139.         ptrTab++;
  140.     }
  141.     cout << currMin << endl;
  142. }
  143.  
  144. int* minTabVal_II(int* ptrTab, int size) {
  145.     int* currMin = ptrTab;
  146.     for (int i = 0; i < size; i++) {
  147.         if (*ptrTab < *currMin)
  148.             currMin = ptrTab;
  149.         ptrTab++;
  150.     }
  151.     cout << *currMin << endl;
  152.     return currMin;
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement