SlideShare a Scribd company logo
PROGRAMA EN C
// ConsoleApplication5.cpp: define el punto de entrada de la aplicación de
consola.
//
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "time.h"
int _tmain(int argc, _TCHAR* argv[])
{
system("color F0");
int i, j, aux, dimension, suma[300], cont, matriz[10][10];
printf("Porfavor ingrese la dimension de la matriz con la que desea
trabajar ");
//srand(time(NULL)); Únicamente se utiliza para generar números aleatorios
pero no fue necesario
scanf_s("%d", &dimension);
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
printf("Digite los elementos de la matriz en la posicion %d %d ", i,
j);
scanf_s("%d", &matriz[i][j]);
}
printf("nn");
}
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
printf("t%d", matriz[i][j]);
}
printf("nn");
}
printf("n");
printf("+++++ Suma de matriz filas +++++");
printf("n");
for (i = 0; i < 2 * dimension + 2; i++)
{
suma[i] = 0;
}
//suma filas
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
suma[i] = suma[i] + matriz[i][j];
printf("t %d", suma[i]);
}
printf("nn");
}
printf("n");
printf("+++++ Suma de matriz columnas +++++");
printf("n");
//suma columnas
for (j = 0; j < dimension; j++)
{
for (i = 0; i < dimension; i++)
{
suma[j + dimension] = suma[j + dimension] + matriz[i][j];
printf("t %d", suma[j + dimension]);
}
printf("nn");
}
printf("n");
printf("+++++ Suma de matriz diagonales +++++");
printf("n");
//suma diagonales
for (i = 0; i < dimension; i++)
{
suma[2 * dimension] = suma[2 * dimension] + matriz[i][i];
printf("t %d", suma[2 * dimension]);
}
printf("nn");
printf("n");
for (i = 0; i < dimension; i++)
{
suma[2 * dimension + 1] = suma[2 * dimension + 1] + matriz[i]
[(dimension - 1) - i];
printf("t %d", suma[2 * dimension + 1]);
}
printf("nn");
//verificar si la matriz es magica
cont = 0;
cont = suma[0];
for (i = 1; i < 2 * dimension + 1; i++)
{
if ((cont != suma[i]))
{
printf("La matriz no es magica");
i = 2 * dimension + 3;
}
else
if (i = 2 * dimension + 2)
{
printf("La matriz es magica y su suma es %d", cont);
}
}
getchar();
getchar();
return 0;
}
--------------------------------------------------------------------------------
----------
PROGRAMA EN JAVA
package javaapplication1;
import java.util.*;
public class JavaApplication1
{
public static void main(String[] args)
{
int i, j, aux, dimension, cont;
Scanner dato=new Scanner(System.in);
System.out.print("Porfavor ingrese la dimension de la matriz con la que
desea trabajar ");
dimension=dato.nextInt();
int matriz[][]=new int[10][10];
int suma[]=new int[300];
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
System.out.print("Digite los elementos de la matriz en la
posicion " + i + j+": " );
matriz[i][j]=dato.nextInt();
}
System.out.print("nn");
}
System.out.println("La matriz es: ");
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
System.out.print("t"+matriz[i][j]);
}
System.out.print("n");
}
System.out.print("n");
System.out.println("+++++ Suma de matriz filas +++++");
for (i = 0; i < 2 * dimension + 2; i++)
{
suma[i] = 0;
}
//suma filas
for (i = 0; i < dimension; i++)
{
for (j = 0; j < dimension; j++)
{
suma[i] = matriz[i][j]+suma[i];
System.out.print("t" + suma[i]);
}
System.out.print("nn");
}
System.out.print("n");
System.out.println("+++++ Suma de matriz columnas +++++");
//suma columnas
for (j = 0; j < dimension; j++)
{
for (i = 0; i < dimension; i++)
{
suma[j + dimension] = matriz[i][j]+suma[j + dimension] ;
System.out.print("t "+ suma[j + dimension]);
}
System.out.print("nn");
}
System.out.print("n");
System.out.println("+++++ Suma de matriz diagonales +++++");
//suma diagonales
for (i = 0; i < dimension; i++)
{
suma[2 * dimension] = matriz[i][i]+suma[2 * dimension] ;
System.out.print("t "+ suma[2 * dimension]);
}
System.out.println("nn");
for (i = 0; i < dimension; i++)
{
suma[2 * dimension + 1] = matriz[i][(dimension - 1) - i]+suma[2 *
dimension + 1] ;
System.out.print("t "+ suma[2 * dimension + 1]);
}
System.out.print("nn");
//verificar si la matriz es magica
cont = 0;
cont = suma[0];
for (i = 1; i < 2 * dimension+1 ; i++)
{
if (cont != suma[i])
{
System.out.println("La matriz no es magica");
i=2*dimension+3;
}
else
{
if (cont == suma[i])
{
System.out.println("La matriz es magica y su suma es
"+cont);
i=2*dimension+3;
}
}
}
}
}
--------------------------------------------------------------------------------
----------------
PROGRAMA EN VISUAL BASIC
Sub stefy()
' Matriz Magica
'
Dim i As Integer
Dim j As Integer
Dim aux As Integer
Dim dimension As Integer
Dim cont As Integer
Dim Matriz(10, 10) As Integer
Dim suma(300) As Integer
dimension = InputBox("Porfavor ingrese la dimension de la matriz con la que
desea trabajar ")
For i = 0 To dimension - 1
For j = 0 To dimension - 1
Matriz(i, j) = InputBox("Digite los elementos de la matriz en la
posicion: " & i & "." & j)
Next j
Next i
Worksheets("Hoja1").Cells(1, 2).Value = ("PROYECTO DE MATRIZ MÁGICA ")
Worksheets("Hoja1").Cells(3, 2).Value = ("La matriz es: ")
Cells(3, 2).Interior.ColorIndex = 39
Cells(3, 2).BorderAround (xlContinuous)
Cells(3, 2).BorderAround (xlHairline)
For i = 0 To dimension - 1
For j = 0 To dimension - 1
Worksheets("Hoja1").Cells(4 + i, 2 + j).Value = (Matriz(i, j))
Cells(4 + i, 2 + j).Interior.ColorIndex = 40
Cells(4 + i, 2 + j).BorderAround (xlContinuous)
Cells(4 + i, 2 + j).BorderAround (xlHairline)
Next j
Next i
For i = 0 To 2 * dimension + 2
suma(i) = 0
Next i
'Suma Filas
Worksheets("Hoja1").Cells(9, 1).Value = ("La suma de sus filas es: ")
Cells(9, 1).Interior.ColorIndex = 43
Cells(9, 1).BorderAround (xlContinuous)
Cells(9, 1).BorderAround (xlHairline)
For i = 0 To dimension - 1
Worksheets("Hoja1").Cells(10 + i, 1).Value = ("Suma fila " & i + 1)
Cells(10 + i, 1).Interior.ColorIndex = 44
Cells(10 + i, 1).BorderAround (xlContinuous)
Cells(10 + i, 1).BorderAround (xlHairline)
For j = 0 To dimension - 1
suma(i) = suma(i) + Matriz(i, j)
Worksheets("Hoja1").Cells(10 + i, 2 + j).Value = (suma(i))
Cells(10 + i, 2 + j).Interior.ColorIndex = 45
Cells(10 + i, 2 + j).BorderAround (xlContinuous)
Cells(10 + i, 2 + j).BorderAround (xlHairline)
Next j
Next i
'Suma Columnas
Worksheets("Hoja1").Cells(15, 1).Value = ("La suma de sus columnas es: ")
Cells(15, 1).Interior.ColorIndex = 10
Cells(15, 1).BorderAround (xlContinuous)
Cells(15, 1).BorderAround (xlHairline)
For j = 0 To dimension - 1
For i = 0 To dimension - 1
suma(j + dimension) = suma(j + dimension) + Matriz(i, j)
Worksheets("Hoja1").Cells(16, 1 + j).Value = ("Suma columna " & j + 1)
Cells(16, 1 + j).Interior.ColorIndex = 44
Cells(16, 1 + j).BorderAround (xlContinuous)
Cells(16, 1 + j).BorderAround (xlHairline)
Worksheets("Hoja1").Cells(17 + i, 1 + j).Value = (suma(j + dimension))
Cells(17 + i, 1 + j).Interior.ColorIndex = 45
Cells(17 + i, 1 + j).BorderAround (xlContinuous)
Cells(17 + i, 1 + j).BorderAround (xlHairline)
Next i
Next j
'Suma Diagonales
j = 0
Worksheets("Hoja1").Cells(21, 1).Value = ("La suma de sus diagonales es: ")
Cells(21, 1).Interior.ColorIndex = 23
Cells(21, 1).BorderAround (xlContinuous)
Cells(21, 1).BorderAround (xlHairline)
For i = 0 To dimension - 1
Worksheets("Hoja1").Cells(22, 1).Value = ("Suma diagonal izq-der ")
Cells(22, 1).Interior.ColorIndex = 46
Cells(22, 1).BorderAround (xlContinuous)
Cells(22, 1).BorderAround (xlHairline)
suma(2 * dimension) = suma(2 * dimension) + Matriz(i, i)
Worksheets("Hoja1").Cells(22 + i, 2 + j).Value = (suma(2 * dimension))
Cells(22 + i, 2 + j).Interior.ColorIndex = 44
Cells(22 + i, 2 + j).BorderAround (xlContinuous)
Cells(22 + i, 2 + j).BorderAround (xlHairline)
j = j + 1
Next i
Worksheets("Hoja1").Cells(22, j + 2).Value = ("Suma diagonal der-izq ")
Cells(22, j + 2).Interior.ColorIndex = 22
Cells(22, j + 2).BorderAround (xlContinuous)
Cells(22, j + 2).BorderAround (xlHairline)
For i = 0 To dimension - 1
suma(2 * dimension + 1) = suma(2 * dimension + 1) + Matriz(i, (dimension -
1) - i)
Worksheets("Hoja1").Cells(22 + i, 3 + j).Value = (suma(2 * dimension + 1))
Cells(22 + i, 3 + j).Interior.ColorIndex = 44
Cells(22 + i, 3 + j).BorderAround (xlContinuous)
Cells(22 + i, 3 + j).BorderAround (xlHairline)
j = j + 1
Next i
'Verificar si la matriz es magica
cont = 0
cont = suma(0)
For i = 1 To 2 * dimension + 1
If (cont = suma(i)) Then
Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz es magica y su suma
es " & cont)
Cells(27, 1).Interior.ColorIndex = 3
Else
If (cont <> suma(i)) Then
Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz no es magica")
Cells(27, 1).Interior.ColorIndex = 3
End If
End If
Next i
End Sub
Worksheets("Hoja1").Cells(17 + i, 1 + j).Value = (suma(j + dimension))
Cells(17 + i, 1 + j).Interior.ColorIndex = 45
Cells(17 + i, 1 + j).BorderAround (xlContinuous)
Cells(17 + i, 1 + j).BorderAround (xlHairline)
Next i
Next j
'Suma Diagonales
j = 0
Worksheets("Hoja1").Cells(21, 1).Value = ("La suma de sus diagonales es: ")
Cells(21, 1).Interior.ColorIndex = 23
Cells(21, 1).BorderAround (xlContinuous)
Cells(21, 1).BorderAround (xlHairline)
For i = 0 To dimension - 1
Worksheets("Hoja1").Cells(22, 1).Value = ("Suma diagonal izq-der ")
Cells(22, 1).Interior.ColorIndex = 46
Cells(22, 1).BorderAround (xlContinuous)
Cells(22, 1).BorderAround (xlHairline)
suma(2 * dimension) = suma(2 * dimension) + Matriz(i, i)
Worksheets("Hoja1").Cells(22 + i, 2 + j).Value = (suma(2 * dimension))
Cells(22 + i, 2 + j).Interior.ColorIndex = 44
Cells(22 + i, 2 + j).BorderAround (xlContinuous)
Cells(22 + i, 2 + j).BorderAround (xlHairline)
j = j + 1
Next i
Worksheets("Hoja1").Cells(22, j + 2).Value = ("Suma diagonal der-izq ")
Cells(22, j + 2).Interior.ColorIndex = 22
Cells(22, j + 2).BorderAround (xlContinuous)
Cells(22, j + 2).BorderAround (xlHairline)
For i = 0 To dimension - 1
suma(2 * dimension + 1) = suma(2 * dimension + 1) + Matriz(i, (dimension -
1) - i)
Worksheets("Hoja1").Cells(22 + i, 3 + j).Value = (suma(2 * dimension + 1))
Cells(22 + i, 3 + j).Interior.ColorIndex = 44
Cells(22 + i, 3 + j).BorderAround (xlContinuous)
Cells(22 + i, 3 + j).BorderAround (xlHairline)
j = j + 1
Next i
'Verificar si la matriz es magica
cont = 0
cont = suma(0)
For i = 1 To 2 * dimension + 1
If (cont = suma(i)) Then
Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz es magica y su suma
es " & cont)
Cells(27, 1).Interior.ColorIndex = 3
Else
If (cont <> suma(i)) Then
Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz no es magica")
Cells(27, 1).Interior.ColorIndex = 3
End If
End If
Next i
End Sub

More Related Content

What's hot

Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Uma mohan
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
vikram mahendra
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
Farhan Ab Rahman
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
Farhan Ab Rahman
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
Ûťţåm Ğűpţä
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
KristhyanAndreeKurtL
 
What We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit TestingWhat We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit Testing
Kevlin Henney
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
Farhan Ab Rahman
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
Bhavesh Shah
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
Farhan Ab Rahman
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
Abdullah Al Shiam
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
Kevlin Henney
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
Farhan Ab Rahman
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 

What's hot (20)

Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Programs in array using SWIFT
Programs in array using SWIFTPrograms in array using SWIFT
Programs in array using SWIFT
 
Chapter2
Chapter2Chapter2
Chapter2
 
C++ TUTORIAL 4
C++ TUTORIAL 4C++ TUTORIAL 4
C++ TUTORIAL 4
 
C++ TUTORIAL 9
C++ TUTORIAL 9C++ TUTORIAL 9
C++ TUTORIAL 9
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Computer Practical XII
Computer Practical XIIComputer Practical XII
Computer Practical XII
 
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericosKristhyan kurtlazartezubia evidencia1-metodosnumericos
Kristhyan kurtlazartezubia evidencia1-metodosnumericos
 
What We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit TestingWhat We Talk About When We Talk About Unit Testing
What We Talk About When We Talk About Unit Testing
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Array
ArrayArray
Array
 
Integral table
Integral tableIntegral table
Integral table
 
SE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of PuneSE Computer, Programming Laboratory(210251) University of Pune
SE Computer, Programming Laboratory(210251) University of Pune
 
C++ TUTORIAL 5
C++ TUTORIAL 5C++ TUTORIAL 5
C++ TUTORIAL 5
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
C++ TUTORIAL 8
C++ TUTORIAL 8C++ TUTORIAL 8
C++ TUTORIAL 8
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 

Viewers also liked

Programacion fantasticos
Programacion  fantasticosProgramacion  fantasticos
Programacion fantasticos
Brenda Jazmin
 
LOS C++
LOS C++LOS C++
LOS C++
Brenda Jazmin
 
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
CamiEscobar1995
 
Los 100 fuegos
Los 100 fuegosLos 100 fuegos
Los 100 fuegos
Brenda Jazmin
 
Informe teórico-getchars-1
Informe teórico-getchars-1Informe teórico-getchars-1
Informe teórico-getchars-1
Brenda Jazmin
 
Los fantastico
Los fantasticoLos fantastico
Los fantastico
Brenda Jazmin
 
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARSUNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
CamiEscobar1995
 
Sesión formativa 15.16
Sesión formativa 15.16Sesión formativa 15.16
Sesión formativa 15.16
Isabel Ibarrola
 
Cómic conflictos
Cómic conflictosCómic conflictos
Cómic conflictos
Isabel Ibarrola
 
Sesión formativa 16.17
Sesión formativa 16.17Sesión formativa 16.17
Sesión formativa 16.17
Isabel Ibarrola
 

Viewers also liked (11)

Programacion fantasticos
Programacion  fantasticosProgramacion  fantasticos
Programacion fantasticos
 
LOS C++
LOS C++LOS C++
LOS C++
 
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
UNIVERSIDAD CENTRAL DEL ECUADOR CAMILA ESCOBAR LOPEZ C+++
 
Los sdkn
Los sdknLos sdkn
Los sdkn
 
Los 100 fuegos
Los 100 fuegosLos 100 fuegos
Los 100 fuegos
 
Informe teórico-getchars-1
Informe teórico-getchars-1Informe teórico-getchars-1
Informe teórico-getchars-1
 
Los fantastico
Los fantasticoLos fantastico
Los fantastico
 
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARSUNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
UNIVERSIDAD CENTRAL DEL ECUADOR GETCHARS
 
Sesión formativa 15.16
Sesión formativa 15.16Sesión formativa 15.16
Sesión formativa 15.16
 
Cómic conflictos
Cómic conflictosCómic conflictos
Cómic conflictos
 
Sesión formativa 16.17
Sesión formativa 16.17Sesión formativa 16.17
Sesión formativa 16.17
 

Similar to Los dskn

.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
Aroosa Rajput
 
2D array
2D array2D array
2D array
A. S. M. Shafi
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
archana singh
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Sunil Yadav
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
Upender Upr
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
Charm Sasi
 
Cpds lab
Cpds labCpds lab
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
Yung-Yu Chen
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
vikram mahendra
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
sowmya koneru
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
paijitk
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
MaruMengesha
 
C programs
C programsC programs
C programs
Koshy Geoji
 
Frsa
FrsaFrsa
Frsa
_111
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptx
TasnimSaimaRaita
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
Yael Zaritsky Perez
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2Mohamed Ahmed
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 

Similar to Los dskn (20)

.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
2D array
2D array2D array
2D array
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
programs on arrays.pdf
programs on arrays.pdfprograms on arrays.pdf
programs on arrays.pdf
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Feb-2021_L6-...
 
Ann
AnnAnn
Ann
 
C programs
C programsC programs
C programs
 
Frsa
FrsaFrsa
Frsa
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptx
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
 
C++ Course - Lesson 2
C++ Course - Lesson 2C++ Course - Lesson 2
C++ Course - Lesson 2
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 

More from Brenda Jazmin

Las getchar
Las getcharLas getchar
Las getchar
Brenda Jazmin
 
LOS 100 FUEGOS
LOS 100 FUEGOSLOS 100 FUEGOS
LOS 100 FUEGOS
Brenda Jazmin
 
LOS SDKN
LOS SDKNLOS SDKN
LOS SDKN
Brenda Jazmin
 
Examen parial recuperación
Examen parial recuperaciónExamen parial recuperación
Examen parial recuperación
Brenda Jazmin
 

More from Brenda Jazmin (7)

Las getchar
Las getcharLas getchar
Las getchar
 
Getchars
GetcharsGetchars
Getchars
 
Los 5 fantasticos
Los 5 fantasticosLos 5 fantasticos
Los 5 fantasticos
 
LOS 100 FUEGOS
LOS 100 FUEGOSLOS 100 FUEGOS
LOS 100 FUEGOS
 
LOS SDKN
LOS SDKNLOS SDKN
LOS SDKN
 
Examen parial recuperación
Examen parial recuperaciónExamen parial recuperación
Examen parial recuperación
 
Los 100 fuegos
Los 100 fuegosLos 100 fuegos
Los 100 fuegos
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 

Los dskn

  • 1. PROGRAMA EN C // ConsoleApplication5.cpp: define el punto de entrada de la aplicación de consola. // #include "stdafx.h" #include "stdio.h" #include "stdlib.h" #include "conio.h" #include "time.h" int _tmain(int argc, _TCHAR* argv[]) { system("color F0"); int i, j, aux, dimension, suma[300], cont, matriz[10][10]; printf("Porfavor ingrese la dimension de la matriz con la que desea trabajar "); //srand(time(NULL)); Únicamente se utiliza para generar números aleatorios pero no fue necesario scanf_s("%d", &dimension); for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { printf("Digite los elementos de la matriz en la posicion %d %d ", i, j); scanf_s("%d", &matriz[i][j]); } printf("nn"); } for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { printf("t%d", matriz[i][j]); } printf("nn"); } printf("n"); printf("+++++ Suma de matriz filas +++++"); printf("n"); for (i = 0; i < 2 * dimension + 2; i++) { suma[i] = 0; } //suma filas for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { suma[i] = suma[i] + matriz[i][j]; printf("t %d", suma[i]); } printf("nn"); } printf("n"); printf("+++++ Suma de matriz columnas +++++"); printf("n");
  • 2. //suma columnas for (j = 0; j < dimension; j++) { for (i = 0; i < dimension; i++) { suma[j + dimension] = suma[j + dimension] + matriz[i][j]; printf("t %d", suma[j + dimension]); } printf("nn"); } printf("n"); printf("+++++ Suma de matriz diagonales +++++"); printf("n"); //suma diagonales for (i = 0; i < dimension; i++) { suma[2 * dimension] = suma[2 * dimension] + matriz[i][i]; printf("t %d", suma[2 * dimension]); } printf("nn"); printf("n"); for (i = 0; i < dimension; i++) { suma[2 * dimension + 1] = suma[2 * dimension + 1] + matriz[i] [(dimension - 1) - i]; printf("t %d", suma[2 * dimension + 1]); } printf("nn"); //verificar si la matriz es magica cont = 0; cont = suma[0]; for (i = 1; i < 2 * dimension + 1; i++) { if ((cont != suma[i])) { printf("La matriz no es magica"); i = 2 * dimension + 3; } else if (i = 2 * dimension + 2) { printf("La matriz es magica y su suma es %d", cont); } } getchar(); getchar(); return 0; } -------------------------------------------------------------------------------- ---------- PROGRAMA EN JAVA package javaapplication1; import java.util.*; public class JavaApplication1 {
  • 3. public static void main(String[] args) { int i, j, aux, dimension, cont; Scanner dato=new Scanner(System.in); System.out.print("Porfavor ingrese la dimension de la matriz con la que desea trabajar "); dimension=dato.nextInt(); int matriz[][]=new int[10][10]; int suma[]=new int[300]; for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { System.out.print("Digite los elementos de la matriz en la posicion " + i + j+": " ); matriz[i][j]=dato.nextInt(); } System.out.print("nn"); } System.out.println("La matriz es: "); for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { System.out.print("t"+matriz[i][j]); } System.out.print("n"); } System.out.print("n"); System.out.println("+++++ Suma de matriz filas +++++"); for (i = 0; i < 2 * dimension + 2; i++) { suma[i] = 0; } //suma filas for (i = 0; i < dimension; i++) { for (j = 0; j < dimension; j++) { suma[i] = matriz[i][j]+suma[i]; System.out.print("t" + suma[i]); } System.out.print("nn"); } System.out.print("n"); System.out.println("+++++ Suma de matriz columnas +++++"); //suma columnas for (j = 0; j < dimension; j++) { for (i = 0; i < dimension; i++) { suma[j + dimension] = matriz[i][j]+suma[j + dimension] ;
  • 4. System.out.print("t "+ suma[j + dimension]); } System.out.print("nn"); } System.out.print("n"); System.out.println("+++++ Suma de matriz diagonales +++++"); //suma diagonales for (i = 0; i < dimension; i++) { suma[2 * dimension] = matriz[i][i]+suma[2 * dimension] ; System.out.print("t "+ suma[2 * dimension]); } System.out.println("nn"); for (i = 0; i < dimension; i++) { suma[2 * dimension + 1] = matriz[i][(dimension - 1) - i]+suma[2 * dimension + 1] ; System.out.print("t "+ suma[2 * dimension + 1]); } System.out.print("nn"); //verificar si la matriz es magica cont = 0; cont = suma[0]; for (i = 1; i < 2 * dimension+1 ; i++) { if (cont != suma[i]) { System.out.println("La matriz no es magica"); i=2*dimension+3; } else { if (cont == suma[i]) { System.out.println("La matriz es magica y su suma es "+cont); i=2*dimension+3; } } } } } -------------------------------------------------------------------------------- ---------------- PROGRAMA EN VISUAL BASIC Sub stefy() ' Matriz Magica ' Dim i As Integer Dim j As Integer Dim aux As Integer Dim dimension As Integer Dim cont As Integer
  • 5. Dim Matriz(10, 10) As Integer Dim suma(300) As Integer dimension = InputBox("Porfavor ingrese la dimension de la matriz con la que desea trabajar ") For i = 0 To dimension - 1 For j = 0 To dimension - 1 Matriz(i, j) = InputBox("Digite los elementos de la matriz en la posicion: " & i & "." & j) Next j Next i Worksheets("Hoja1").Cells(1, 2).Value = ("PROYECTO DE MATRIZ MÁGICA ") Worksheets("Hoja1").Cells(3, 2).Value = ("La matriz es: ") Cells(3, 2).Interior.ColorIndex = 39 Cells(3, 2).BorderAround (xlContinuous) Cells(3, 2).BorderAround (xlHairline) For i = 0 To dimension - 1 For j = 0 To dimension - 1 Worksheets("Hoja1").Cells(4 + i, 2 + j).Value = (Matriz(i, j)) Cells(4 + i, 2 + j).Interior.ColorIndex = 40 Cells(4 + i, 2 + j).BorderAround (xlContinuous) Cells(4 + i, 2 + j).BorderAround (xlHairline) Next j Next i For i = 0 To 2 * dimension + 2 suma(i) = 0 Next i 'Suma Filas Worksheets("Hoja1").Cells(9, 1).Value = ("La suma de sus filas es: ") Cells(9, 1).Interior.ColorIndex = 43 Cells(9, 1).BorderAround (xlContinuous) Cells(9, 1).BorderAround (xlHairline) For i = 0 To dimension - 1 Worksheets("Hoja1").Cells(10 + i, 1).Value = ("Suma fila " & i + 1) Cells(10 + i, 1).Interior.ColorIndex = 44 Cells(10 + i, 1).BorderAround (xlContinuous) Cells(10 + i, 1).BorderAround (xlHairline) For j = 0 To dimension - 1 suma(i) = suma(i) + Matriz(i, j) Worksheets("Hoja1").Cells(10 + i, 2 + j).Value = (suma(i)) Cells(10 + i, 2 + j).Interior.ColorIndex = 45 Cells(10 + i, 2 + j).BorderAround (xlContinuous) Cells(10 + i, 2 + j).BorderAround (xlHairline) Next j Next i 'Suma Columnas Worksheets("Hoja1").Cells(15, 1).Value = ("La suma de sus columnas es: ") Cells(15, 1).Interior.ColorIndex = 10 Cells(15, 1).BorderAround (xlContinuous) Cells(15, 1).BorderAround (xlHairline) For j = 0 To dimension - 1 For i = 0 To dimension - 1 suma(j + dimension) = suma(j + dimension) + Matriz(i, j) Worksheets("Hoja1").Cells(16, 1 + j).Value = ("Suma columna " & j + 1) Cells(16, 1 + j).Interior.ColorIndex = 44 Cells(16, 1 + j).BorderAround (xlContinuous) Cells(16, 1 + j).BorderAround (xlHairline)
  • 6. Worksheets("Hoja1").Cells(17 + i, 1 + j).Value = (suma(j + dimension)) Cells(17 + i, 1 + j).Interior.ColorIndex = 45 Cells(17 + i, 1 + j).BorderAround (xlContinuous) Cells(17 + i, 1 + j).BorderAround (xlHairline) Next i Next j 'Suma Diagonales j = 0 Worksheets("Hoja1").Cells(21, 1).Value = ("La suma de sus diagonales es: ") Cells(21, 1).Interior.ColorIndex = 23 Cells(21, 1).BorderAround (xlContinuous) Cells(21, 1).BorderAround (xlHairline) For i = 0 To dimension - 1 Worksheets("Hoja1").Cells(22, 1).Value = ("Suma diagonal izq-der ") Cells(22, 1).Interior.ColorIndex = 46 Cells(22, 1).BorderAround (xlContinuous) Cells(22, 1).BorderAround (xlHairline) suma(2 * dimension) = suma(2 * dimension) + Matriz(i, i) Worksheets("Hoja1").Cells(22 + i, 2 + j).Value = (suma(2 * dimension)) Cells(22 + i, 2 + j).Interior.ColorIndex = 44 Cells(22 + i, 2 + j).BorderAround (xlContinuous) Cells(22 + i, 2 + j).BorderAround (xlHairline) j = j + 1 Next i Worksheets("Hoja1").Cells(22, j + 2).Value = ("Suma diagonal der-izq ") Cells(22, j + 2).Interior.ColorIndex = 22 Cells(22, j + 2).BorderAround (xlContinuous) Cells(22, j + 2).BorderAround (xlHairline) For i = 0 To dimension - 1 suma(2 * dimension + 1) = suma(2 * dimension + 1) + Matriz(i, (dimension - 1) - i) Worksheets("Hoja1").Cells(22 + i, 3 + j).Value = (suma(2 * dimension + 1)) Cells(22 + i, 3 + j).Interior.ColorIndex = 44 Cells(22 + i, 3 + j).BorderAround (xlContinuous) Cells(22 + i, 3 + j).BorderAround (xlHairline) j = j + 1 Next i 'Verificar si la matriz es magica cont = 0 cont = suma(0) For i = 1 To 2 * dimension + 1 If (cont = suma(i)) Then Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz es magica y su suma es " & cont) Cells(27, 1).Interior.ColorIndex = 3 Else If (cont <> suma(i)) Then Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz no es magica") Cells(27, 1).Interior.ColorIndex = 3 End If End If Next i End Sub
  • 7. Worksheets("Hoja1").Cells(17 + i, 1 + j).Value = (suma(j + dimension)) Cells(17 + i, 1 + j).Interior.ColorIndex = 45 Cells(17 + i, 1 + j).BorderAround (xlContinuous) Cells(17 + i, 1 + j).BorderAround (xlHairline) Next i Next j 'Suma Diagonales j = 0 Worksheets("Hoja1").Cells(21, 1).Value = ("La suma de sus diagonales es: ") Cells(21, 1).Interior.ColorIndex = 23 Cells(21, 1).BorderAround (xlContinuous) Cells(21, 1).BorderAround (xlHairline) For i = 0 To dimension - 1 Worksheets("Hoja1").Cells(22, 1).Value = ("Suma diagonal izq-der ") Cells(22, 1).Interior.ColorIndex = 46 Cells(22, 1).BorderAround (xlContinuous) Cells(22, 1).BorderAround (xlHairline) suma(2 * dimension) = suma(2 * dimension) + Matriz(i, i) Worksheets("Hoja1").Cells(22 + i, 2 + j).Value = (suma(2 * dimension)) Cells(22 + i, 2 + j).Interior.ColorIndex = 44 Cells(22 + i, 2 + j).BorderAround (xlContinuous) Cells(22 + i, 2 + j).BorderAround (xlHairline) j = j + 1 Next i Worksheets("Hoja1").Cells(22, j + 2).Value = ("Suma diagonal der-izq ") Cells(22, j + 2).Interior.ColorIndex = 22 Cells(22, j + 2).BorderAround (xlContinuous) Cells(22, j + 2).BorderAround (xlHairline) For i = 0 To dimension - 1 suma(2 * dimension + 1) = suma(2 * dimension + 1) + Matriz(i, (dimension - 1) - i) Worksheets("Hoja1").Cells(22 + i, 3 + j).Value = (suma(2 * dimension + 1)) Cells(22 + i, 3 + j).Interior.ColorIndex = 44 Cells(22 + i, 3 + j).BorderAround (xlContinuous) Cells(22 + i, 3 + j).BorderAround (xlHairline) j = j + 1 Next i 'Verificar si la matriz es magica cont = 0 cont = suma(0) For i = 1 To 2 * dimension + 1 If (cont = suma(i)) Then Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz es magica y su suma es " & cont) Cells(27, 1).Interior.ColorIndex = 3 Else If (cont <> suma(i)) Then Worksheets("Hoja1").Cells(27, 1).Value = ("La matriz no es magica") Cells(27, 1).Interior.ColorIndex = 3 End If End If Next i End Sub