Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- void foo(int &);
- int main () {
- int nCount = 20,
- nArr[20] ;
- for (int i = 0; i < nCount; i++) {
- nArr[i] = rand()%1000;
- cout << nArr[i] << endl;
- }
- foo(nArr[11]); //?
- }
- /////////////////////////////////////////////////////////
- void foo(int &Arr) //
- {
- cout << "------" << endl;
- int *p = &Arr;
- int *p2 = p -= 11;
- for(int i = 0; i < 20; i++) {
- cout << p[i] << endl;
- }
- }
- /*
- #include <iostream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- void foo(int *Arr);
- int main () {
- int nCount = 20,
- nArr[20] ;
- for (int i = 0; i < nCount; i++) {
- nArr[i] = rand()%1000;
- cout << nArr[i] << endl;
- }
- foo(&nArr[11]); //?
- }
- /////////////////////////////////////////////////////////
- void foo(int *Arr) //
- {
- cout << "------" << endl;
- int *p = Arr -= 11;
- for(int i = 0; i < 20; i++) {
- cout << p[i] << endl;
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement