Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. ZAD 1.
  2. #include <iostream>
  3. using namespace std;
  4. int main(){
  5.  
  6. int *duzy;
  7. int* maly;
  8. int index;
  9. int tablica[10] = {0,1,2,3,4,5,6,7,8,9};
  10. maly = &tablica[5];
  11. cout << "Na ktorym elemencie tablicy ustawic duzy wskaznik?";
  12. cin >> index;
  13. duzy = &tablica[index];
  14. if (duzy < maly) cout << "Wskaznik duzy pokazuje na element blizej poczatku tablicy";
  15. else if (duzy > maly) cout << "Wskaznik duzy pokazuje element o wyzszym indeksie";
  16. else cout << "Wskazniki pokazuja ten sam element";
  17. }
  18.  
  19.  
  20. ZAD 2.
  21.  
  22. #include <iostream>
  23. using namespace std;
  24. int main(){
  25.  
  26. int tab1[10];
  27. double tab2[10];
  28. int* wsk1 = nullptr;
  29. double* wsk2;
  30. wsk2 = &tab2[0];
  31.  
  32. for (int i = 0; i < 10; i=i++) {
  33. tab1[i] = i;
  34. tab2[i] = i + 0.1;
  35. }
  36. cout << "TABLICA 1: ";
  37. for (int i = 0; i < 10; i = i++) {
  38. cout << tab1[i] << "\t";
  39. }
  40. cout << "\n" << "TABLICA 2: ";
  41. for (int i = 0; i < 10; i = i++) {
  42. cout << tab2[i] << "\t";
  43. }
  44. wsk1 = &tab1[4];
  45. wsk2 = &tab2[2];
  46. *wsk1 = 100;
  47. *wsk2 = 20.5;
  48. cout << "\n \n \n"<< "TABLICA 1: ";
  49. for (int i = 0; i < 10; i = i++) {
  50. cout << tab1[i] << "\t";
  51. }
  52. cout << "\n" << "TABLICA 2: ";
  53. for (int i = 0; i < 10; i = i++) {
  54. cout << tab2[i] << "\t";
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement