-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (45 loc) · 1.53 KB
/
main.cpp
File metadata and controls
51 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
extern "C" {
int calcularMCD(int a, int b);
int sumarArreglo(int* arr, int size);
}
int main() {
int opcion = 0;
std::cout << "======= PROGRAMA HÍBRIDO ASM + C++ =======" << std::endl;
while (opcion != 3) {
std::cout << "\n1. Calcular MCD\n2. Sumar arreglo\n3. Salir\nOpción: ";
std::cin >> opcion;
switch (opcion) {
case 1: {
int a, b;
std::cout << "Ingrese el primer número: ";
std::cin >> a;
std::cout << "Ingrese el segundo número: ";
std::cin >> b;
int resultado = calcularMCD(a, b);
std::cout << "El MCD es: " << resultado << std::endl;
break;
}
case 2: {
int n;
std::cout << "Ingrese tamaño del arreglo: ";
std::cin >> n;
int* arr = new int[n];
for (int i = 0; i < n; i++) {
std::cout << "Elemento [" << i << "]: ";
std::cin >> arr[i];
}
int suma = sumarArreglo(arr, n);
std::cout << "La suma es: " << suma << std::endl;
delete[] arr;
break;
}
case 3:
std::cout << "Saliendo..." << std::endl;
break;
default:
std::cout << "Opción inválida." << std::endl;
}
}
return 0;
}