commit 88025411727ed619a9940775f09ddb7cbea5fe64 parent 26522466c62c95829132a7b3e0f7c2ae7404fc71 Author: Martin Kloeckner <mjkloeckner@gmail.com> Date: Fri, 29 Mar 2024 20:32:07 -0300 Add solutions for `guia2` Diffstat:
| A | solutions/guia2/ej01.cpp | | | 37 | +++++++++++++++++++++++++++++++++++++ |
1 file changed, 37 insertions(+), 0 deletions(-) diff --git a/solutions/guia2/ej01.cpp b/solutions/guia2/ej01.cpp @@ -0,0 +1,37 @@ +#include <iostream> + +int main (void) { + int a, b, *p, *q; + + a = 10; + b = 20; + p = &a; + + std::cout << a << std::endl; + std::cout << &a << std::endl; + std::cout << p << std::endl; + std::cout << *p << std::endl; + std::cout << &p << std::endl; + + q = &a; + std::cout << q << std::endl; + std::cout << *q << std::endl; + std::cout << &q << std::endl; + + (*p)++; + std::cout << a << std::endl; + + q = &b; + *p = *q; + + std::cout << p << std::endl; + std::cout << *p << std::endl; + std::cout << &p << std::endl; + + p = q; + std::cout << p << std::endl; + std::cout << *p << std::endl; + std::cout << &p << std::endl; + + return 0; +}
