Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <list>
- using namespace std;
- void print(int *p, int n);
- void print(list<int> &r);
- /////////////////////////////////////////////////////
- int main()
- {
- list<int> L1;
- int nArr[20] = {2, 5, 3, 8, 43, 222, 4, 77};
- L1.push_back(123);
- L1.push_front(44);
- for(int i = 0; i < 5; i++) L1.push_back(i);
- printf("size of L1 = %d\n", L1.size());
- print(nArr, 20) ;
- print(L1);
- }
- /////////////////////////////////////////////////////
- void print(list<int> &r) //
- {
- list<int>::iterator it = r.begin();
- printf("\n");
- for(int i = 0; i < r.size(); i++)
- {
- printf("%d, ", *it);
- it++;
- }
- }
- /////////////////////////////////////////////////////
- void print(int *p, int n) //
- {
- for(int i = 0; i < n; i++)
- {
- printf("%d, ", p[i]);
- }
- }
- /*
- int foo (int n);
- int SONY(int n);
- int (*fp) (int);
- #include <iostream>
- using namespace std;
- int foo (int n);
- int SONY(int n);
- int (*fp) (int);
- /////////////////////////////////////////////////////
- int main()
- {
- cout << "adr foo " << (int)foo << endl;
- fp = foo;
- cout << "foo = " << fp(4) << endl;
- cout << "foo = " << foo(3) << endl;
- cout << "fp = " << (int)fp << endl;
- fp = SONY;
- cout << "SONY = " << fp(11) << endl;
- }
- ////////////////////////////////////////////////////////
- int foo(int n)
- {
- return n * 10;
- }
- ////////////////////////////////////////////////////////
- int SONY(int n)
- {
- return n - 10;
- }
- */
- /*
- #include <iostream>
- using namespace std;
- /////////////////////////////////////////////////////
- int summa(int n)
- {
- return 100 + n;
- }
- /////////////////////////////////////////////////////
- int summa(int n, int n2)
- {
- return n + n2;
- }
- /////////////////////////////////////////////////////
- double summa(double f, int n)
- {
- return f + n;
- }
- /////////////////////////////////////////////////////
- void summa(double f, float f2)
- {
- cout << f + (double)f2;
- }
- /////////////////////////////////////////////////////
- int main()
- {
- cout << "summa = " << summa(3 ) << endl;
- cout << "summa = " << summa(3, 7) << endl;
- cout << "summa = " << summa(3.2, 7) << endl;
- // cout << "summa = " << summa(1.2, 2.5) << endl;
- summa(1.2, 2.5);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement