
programa 37
unidimensional
Snippet options
Download: Download snippet as programa-37.c.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!
#include<stdio.h> #include<windows.h> void leermatriz(); void imprimirmatriz(); void imprimirdiagonales(); int fila, columna,i,j; int matriz[50][50]; int main() { printf("\nPrograma 37 que imprima los elementos de las diagonales en un arreglo unidimensional"); leermatriz(); imprimirmatriz(); imprimirdiagonales(); } void leermatriz() { printf("\nLectura de matriz"); do{printf("\nDame la cantidad de fila=>"); scanf("%d",&fila); printf("Dame la cantidad de columnas=>"); scanf("%d",&columna); if(fila!=columna) { printf("\nNumero de filas debe ser igual al de columnas"); } }while(fila!=columna); for(i=0;i<fila;i++){ for(j=0;j<columna;j++){ printf("\nDame el valor de la casilla[%d][%d]",i,j); scanf("%d",&matriz[i][j]); } } system("pause"); return; } void imprimirmatriz() { printf("\nMatriz"); for(i=0;i<fila;i++){ printf("\n"); for(j=0;j<columna;j++){ printf("\t%d",matriz[i][j]); } } system("pause"); return; } void imprimirdiagonales() { printf("\nElemnetos de las diagonales"); for(i=0;i<fila;i++){ for(j=0;j<columna;j++){ if(i+j==fila-1||i==j) { printf("\n%d",matriz[i][j]); } } } system("Pause"); return; }
Create a free my code stock.com account now.
my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!
Find out more and register nowYou can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.