Advertisement
Guest User

zadanie 2

a guest
May 4th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. // zadanko2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include "void1.h"
  7. #include "void2.h"
  8.  
  9.  
  10. using namespace std;
  11.  
  12.  
  13. void funk3(int *);
  14. int x = 2;
  15. double funk4 ( int z )
  16. {
  17. return z+0.5;
  18. }
  19. int main()
  20.  
  21. {
  22. int a, b, c;
  23.  
  24.  
  25. a = 2;
  26. b = 5;
  27.  
  28. cout << "Liczba a = " << a << endl;
  29. cout << "Liczba b = " << b << endl;
  30.  
  31.  
  32.  
  33. const float cv = 2.5;
  34. cout << "\nPodaj liczbe ktora program ma pomnozyc przez 2.5\n";
  35. cin >> c;
  36. cout << "Wynik mnozenia 2.5*" << c << "= " << cv*c << endl;
  37.  
  38.  
  39. int d = 6;
  40. int &ref_d = d;
  41. cout << "\nWartosc d = " << d << endl;
  42. ref_d = 1;
  43. cout << "Wartosc referencji d = " << ref_d << endl;
  44. cout << "Wartosc po referencji = " << d << endl;
  45.  
  46.  
  47. int e = 0;
  48. int *wsk_e = &e;
  49. cout << "\nWartosc e = " << e << endl;
  50. *wsk_e = 1;
  51. cout << "Wartosc referencji przy uzyciu wskaznika = " << *wsk_e << endl;
  52. cout << "Wartosc e po referencji = " << e << endl << endl;
  53.  
  54.  
  55. cout << "\nPrzykladowe uzycie zmiennej char f o wartosci 127" << endl;
  56. char f = 127;
  57. cout << "f jest ukazane jako znak '" << f << "'" << endl << endl;
  58.  
  59.  
  60.  
  61.  
  62.  
  63. cout << "\nDwuelementowa tablica:" << endl;
  64.  
  65. int *tab = new int[2];
  66. for (int g = 0; g < 2; g++)
  67. {
  68.  
  69. cout << " ";
  70. cin >> tab[g];
  71. }
  72.  
  73. delete[] tab;
  74.  
  75.  
  76. cout << "\nWart X przed wywolaniem:" << x << endl;
  77. funk1(x);
  78. cout << "Wart X po wywolaniu:" << x << endl;
  79.  
  80. x = 5;
  81. cout << "\nWart X przed wywolaniem:" << x << endl;
  82. funk2(x);
  83. cout << "Wart X po wywolaniu:" << x << endl;
  84.  
  85. x = 5;
  86. cout << "\nWart X przed wywolaniem:" << x << endl;
  87. funk3(&x);
  88. cout << "Wart X po wywolaniu:" << x << endl<<endl;
  89.  
  90.  
  91. //Tablica wskaznikow na funkcje
  92. double (* tab_wsk_fun [5] ) (int) ;
  93. tab_wsk_fun [5] = funk4 ;
  94.  
  95.  
  96. system("PAUSE");
  97.  
  98. return 0;
  99. }
  100.  
  101. void funk3(int *x)
  102. {
  103. std::cout << "wartosc X w funkcji:" << *x << std::endl;
  104. *x = 1;
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement