Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- template <class T>
- void foo(T &);
- /////////////////////////////////////////////////////////////
- int main()
- {
- char sz[20] = "Paramount Pictures.";
- foo(sz[11]);
- }
- template <typename T> //<class >
- //////////////////////////////////////////////////////////////
- void foo(T &a)
- {
- T *pn = &a;
- for (int i = -11; i < 10; i++)
- {
- //printf("%d ", pn[i]);
- cout << pn[i] << " ";
- }
- }
- /*
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- template <class T>
- void foo(T &);
- /////////////////////////////////////////////////////////////
- int main()
- {
- int a[20]; //srand(time(0));
- for(int i = 0; i<20;i++)
- {
- a[i] = rand()%200;
- printf("%d ", a[i]);
- }
- printf("\n" );
- foo(a[11]);
- }
- template <typename T> //<class >
- //////////////////////////////////////////////////////////////
- void foo(T &a)
- {
- T *pn = &a;
- for (int i = -11; i < 10; i++)
- {
- //printf("%d ", pn[i]);
- cout << pn[i] << " ";
- }
- }
- */
- /*
- #include <stdio.h>
- #include <locale.h>
- #include <time.h>
- #include <stdlib.h>
- void foo(int &);
- /////////////////////////////////////////////////////////////
- int main()
- {
- int a [20];
- //srand(time(0));
- for(int i = 0; i<20;i++)
- {
- a[i] = rand()%200;
- printf("%d ", a[i]);
- }
- printf("\n" );
- foo(a[11]);
- }
- //////////////////////////////////////////////////////////////
- void foo(int &a)
- {
- int *pn = &a;
- for (int i = -11; i < 0; i++)
- {
- printf("%d ", pn[i]);
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement