diagonales
C
RECORRER DIAGONALES
La prinicpal no
| 0| 1 | 2 | 3 | 4 | 5|
0|_P_|__*_|__*|_*_|_*_|_*|
1|___|_P__|__*|__*|_*_|_*|
2|___|____|_P_|_*_|_*_|*_|
3|___|____|___|P_|_*_|_*_|
4|___|____|___|___|_P_|*_|
4|___|____|___|___|___|P_|
d1 d2 d3 d4 d5
(0, 1) (0, 2) (0, 3) (0, 4) (0, 5)
(1, 2) (1, 3) (1, 4) (1, 5)
(2, 3) (2, 4) (2, 5)
(3, 4) (3, 5)
(4, 5)
(i, j)
#define kDIM 6
typedef int TMatriz[kDIM][kDIM]; //es cuadrada
void imprimir_diagonales(TMatriz m){
int d, i, j, suma;
for(d = 1; d < kDIM; d++){
i = 0;
j = d;
suma = 0;
while(j < kDIM){
suma = suma + m[i][j];
i++;
j++;
}
printf("%d\n", suma);
}
}
//si no fuera cuadrada:
void imprimir_diagonales(TMatriz m){
int d, i, j, suma;
for(d = 1; d < columnas; d++){
i = 0;
j = d;
suma = 0;
while(i < filas && j < columnas){
suma = suma + m[i][j];
i++;
j++;
}
printf("%d\n", suma);
}
}
| 0| 1 | 2 | 3 | 4 | 5|
0|_*_|__*_|_*_|_*_|_*_|*_|
1|__*|_*__|__*|__*|_*_|__|
2|_*_|__*_|_*_|_*_|___|__|
3|_*_|_*__|_*_|___|___|__|
4|__*|__*_|___|___|___|__|
5|_*_|____|___|___|__|___|
d0 d1 d2 d3 d4 d5
(0, 0) (1, 0) (2, 0) (3, 0) (4, 0) (5, 0)
(0, 1) (1, 1) (2, 1) (3, 1) (4, 1)
(0, 2) (1, 2) (2, 2) (3, 2)
(0, 3) (1, 3) (2, 3)
(0, 4) (1, 4)
(0, 5)
(i, j)
void sumamayor(TMatriz m){
int d, i, j;
int suma = 0;
for(d = 0; d < kDIM; d++){
suma = 0;
for(i = d, j = 0; i >= 0; i--, j++){
suma = suma + m[i][j];
}
printf("suma: %d\n ", suma);
}
}
//recorrer todas las diagonales a partir de la esquina inferior izquierda
std::vector<int> diagonal(const TMatrix& a){
int d, i, j;
std::vector<int> res;
int filas, columnas;
int suma;
filas = a.size();
columnas = a[0].size();
//1ª parte:
for(d = filas - 1; d >= 0; d--){
i = d;
j = 0;
suma = 0;
while(i < filas && j < columnas){
suma = suma + a[i][j];
i++;
j++;
}
res.push_back(suma);
}
//2ª parte:
for(d = 0; d < columnas; d++){
i = 0;
j = d;
suma = 0;
while(i < filas && j < columnas){
suma = suma + a[i][j];
i++;
j++;
}
res.push_back(suma);
}
return res;
}
Also in C:
- Title
- select all file from date powershell
- Category
- C
- Title
- entity framework core discard changes
- Category
- C
- Title
- windowns 10 allow ping
- Category
- C
- Title
- diferencia entre * y & en c
- Category
- C
- Title
- c bit access union
- Category
- C
- Title
- es palindromo
- Category
- C
- Title
- link whatsapp to website
- Category
- C
- Title
- hostbuilder add environment variables
- Category
- C
- Title
- what is strikethrough in markdown
- Category
- C
- Title
- generate all permutations of string
- Category
- C
- Title
- how to find the ith row of pascal's triangle in c
- Category
- C
- Title
- c print array
- Category
- C
- Title
- how to login to another user in powershell
- Category
- C
- Title
- download android ndk r 16
- Category
- C
- Title
- arduino digital input pins
- Category
- C
- Title
- function pointer c
- Category
- C
- Title
- c check if char is an operator
- Category
- C
- Title
- C largest unsigned int
- Category
- C
- Title
- find string in all files powershell
- Category
- C
- Title
- CL/cl.h: No such file or directory
- Category
- C
- Title
- c printf right pad with space
- Category
- C
- Title
- sustituir un dígito por otro
- Category
- C
- Title
- add border to image android
- Category
- C
- Title
- c get first n characters of string
- Category
- C
- Title
- read files in c
- Category
- C
- Title
- entete
- Category
- C
- Title
- how to comment in arduino
- Category
- C
- Title
- ModuleNotFoundError: No module named 'tensorboardX'
- Category
- C
- Title
- read from stdin c
- Category
- C
- Title
- change no_turbo
- Category
- C
- Title
- c pause for 1 second
- Category
- C
- Title
- version of libgcc
- Category
- C
- Title
- c program to perform transpose of a matrix
- Category
- C
- Title
- write array of char to file in c
- Category
- C
- Title
- allocate memory c
- Category
- C
- Title
- bella ciao lyrics
- Category
- C
- Title
- c check if file was created
- Category
- C
- Title
- changing tuple values
- Category
- C
- Title
- reset style matplotlib
- Category
- C
- Title
- 'int' is not a subtype of type 'double' dart
- Category
- C
- Title
- delete docker image repository none
- Category
- C
- Title
- how to print in c
- Category
- C
- Title
- docker images command
- Category
- C
- Title
- buscar caracter
- Category
- C
- Title
- objective c swizzle method
- Category
- C
- Title
- get_session` is not available when using TensorFlow 2.0.
- Category
- C
- Title
- c vs python
- Category
- C
- Title
- how to go to top of file in vim
- Category
- C
- Title
- code wars responsable drinker
- Category
- C
- Title
- how to open chrome using cmd
- Category
- C
- Title
- classification report to excel
- Category
- C
- Title
- c concatenate strings
- Category
- C
- Title
- passing 2d array as parameter to function in c
- Category
- C
- Title
- how to feed a char array to function in C
- Category
- C
- Title
- \0 in c
- Category
- C
- Title
- convert string to float c
- Category
- C
- Title
- c substring
- Category
- C
- Title
- c list
- Category
- C
- Title
- pass the pointer in C
- Category
- C
- Title
- get regedit value cmd
- Category
- C
- Title
- program using if statement in c whether numnber is less eqaul to greater than 50
- Category
- C
- Title
- doubly linked list c
- Category
- C
- Title
- how to put a struct in another struct C
- Category
- C
- Title
- reset c array to zero
- Category
- C
- Title
- full screen on c
- Category
- C
- Title
- How to pull images from Docker Registry
- Category
- C
- Title
- how to make a linked list in c
- Category
- C
- Title
- time now c
- Category
- C
- Title
- Declare macro
- Category
- C
- Title
- ModuleNotFoundError: No module named 'cv2'
- Category
- C
- Title
- C why is is & nit used in scan f fr string
- Category
- C
- Title
- how to write function in c
- Category
- C
- Title
- enum c
- Category
- C
- Title
- error: dereferencing pointer to incomplete type
- Category
- C
- Title
- double return type in c
- Category
- C
- Title
- where is my vimrc
- Category
- C
- Title
- lelcetric fied
- Category
- C
- Title
- error: ‘istringstream’ is not a member of ‘std’
- Category
- C
- Title
- ModuleNotFoundError: No module named 'easydict'
- Category
- C
- Title
- printf("%3d ",XX);
- Category
- C
- Title
- Declaring Variables in C
- Category
- C
- Title
- c print hello world
- Category
- C
- Title
- how to sleep in c
- Category
- C
- Title
- how to globally initlailize a struct
- Category
- C
- Title
- how to ascii art in c
- Category
- C
- Title
- primo
- Category
- C
- Title
- c matrix sintax
- Category
- C
- Title
- write a binary file c
- Category
- C
- Title
- arduino digital read
- Category
- C
- Title
- division recursiva
- Category
- C
- Title
- how to download file in powershell
- Category
- C
- Title
- c if int
- Category
- C
- Title
- coin row problem in linear time
- Category
- C
- Title
- use of matplotlib inline
- Category
- C
- Title
- delete string function in c
- Category
- C
- Title
- declaring a volatile in c
- Category
- C
- Title
- maximo comun divisor
- Category
- C
- Title
- es par
- Category
- C
- Title
- how can i remove a specific item from an array
- Category
- C
- Title
- piramide
- Category
- C