Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZAD 1.
- #include <iostream>
- using namespace std;
- int main(){
- int *duzy;
- int* maly;
- int index;
- int tablica[10] = {0,1,2,3,4,5,6,7,8,9};
- maly = &tablica[5];
- cout << "Na ktorym elemencie tablicy ustawic duzy wskaznik?";
- cin >> index;
- duzy = &tablica[index];
- if (duzy < maly) cout << "Wskaznik duzy pokazuje na element blizej poczatku tablicy";
- else if (duzy > maly) cout << "Wskaznik duzy pokazuje element o wyzszym indeksie";
- else cout << "Wskazniki pokazuja ten sam element";
- }
- ZAD 2.
- #include <iostream>
- using namespace std;
- int main(){
- int tab1[10];
- double tab2[10];
- int* wsk1 = nullptr;
- double* wsk2;
- wsk2 = &tab2[0];
- for (int i = 0; i < 10; i=i++) {
- tab1[i] = i;
- tab2[i] = i + 0.1;
- }
- cout << "TABLICA 1: ";
- for (int i = 0; i < 10; i = i++) {
- cout << tab1[i] << "\t";
- }
- cout << "\n" << "TABLICA 2: ";
- for (int i = 0; i < 10; i = i++) {
- cout << tab2[i] << "\t";
- }
- wsk1 = &tab1[4];
- wsk2 = &tab2[2];
- *wsk1 = 100;
- *wsk2 = 20.5;
- cout << "\n \n \n"<< "TABLICA 1: ";
- for (int i = 0; i < 10; i = i++) {
- cout << tab1[i] << "\t";
- }
- cout << "\n" << "TABLICA 2: ";
- for (int i = 0; i < 10; i = i++) {
- cout << tab2[i] << "\t";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement