Matrices
package mapas;
import java.util.Scanner;
public class carto{
public static void main(String[] args) {
Scanner lea= new Scanner(System.in);
double x[] []=new double[50][50];
double y[] []=new double[50][50];
double z[] []=new double[50][50];
double n,m;
System.out.println("Ingrese el numero de filas");
n=lea.nextDouble();
System.out.println("Ingrese el numero de columnas");
m=lea.nextDouble();
leermatriz(n,m,x);
//leermatriz(n,m,y);
imprimirmatriz(n,m,x);
//imprimirmatriz(n,m,y);
//sumarmatrices(n,m,x,y,z);
//mayor(n,m,x);
//vectoruno(m,n,x);
//vectordos(m,n,y);
vectortres(n,m,x);
vectorcuatro(n,m,x);
// encotrar el minimo de vector tres y el maximo de vector cuatro y si son iguales
//existe el punto de silla de montar
}
private static void vectorcuatro(double n, double m, double[][] x) {
double menor=x[1][1];
double w[]=new double [20];
double guardar=0;
for (int i=1; i<=m; i++){
menor=x[1][i];
for (int j=1; j<=n; j++){
if (menor>x[j][i]){
menor=x[j][i];
w[i]=menor;
}
else {
w[i]=menor;
}
}
}
for (int k=1; k<=m; k++){
System.out.println(w[k]);
}
}
private static void vectortres(double n, double m, double[][] x) {
double mayor=x[1][1];
double menor=x[1][1];
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
if (mayor <x[i][j]){
mayor=x[i][j];
z[i]=mayor;
}
}
mayor=0;
}
for (int k=1; k<=n; k++){
System.out.println(z[k]);
}
}
private static void mayor(double n, double m, double[][] x) {
int fila = 1,columna=1;
double mayor=x[1][1];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
if (mayor<x[i][j]){
mayor=x[i][j];
fila=i;
columna=j;
}
}
}
System.out.println("el mayor es: "+mayor+" esta en la fila "+fila+" y en la columna "+columna);
}
private static void vectordos(double m, double n, double[][] y) {
double sumafila=0;
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
sumafila=sumafila+y[i][j];
}z[i]=sumafila;
sumafila=0;
}for (int k=1; k<=n; k++){
System.out.print(" "+z[k]);
}
}
private static void vectoruno(double m, double n, double[][] x) {
double sumafila=0;
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
sumafila=sumafila+x[i][j];
}z[i]=sumafila;
sumafila=0;
}for (int k=1; k<=n; k++){
System.out.print(" "+z[k]);
}System.out.println("");
}
private static void sumarmatrices(double n, double m, double[][] x, double[][] y, double[][] z) {
System.out.println("\t");
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
z[i][j]=x[i][j]+y[i][j];
System.out.print(" "+z[i][j]);
}
System.out.println("\t");
}
}
private static void imprimirmatriz(double n, double m, double[][] x) {
System.out.println("\n");
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
System.out.print(" "+x[i][j]);
}
System.out.println("\t");
}
}
private static void leermatriz(double n, double m, double[][] x) {
Scanner lea= new Scanner(System.in);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
x[i][j]=lea.nextDouble();
}
}
}
}
import java.util.Scanner;
public class carto{
public static void main(String[] args) {
Scanner lea= new Scanner(System.in);
double x[] []=new double[50][50];
double y[] []=new double[50][50];
double z[] []=new double[50][50];
double n,m;
System.out.println("Ingrese el numero de filas");
n=lea.nextDouble();
System.out.println("Ingrese el numero de columnas");
m=lea.nextDouble();
leermatriz(n,m,x);
//leermatriz(n,m,y);
imprimirmatriz(n,m,x);
//imprimirmatriz(n,m,y);
//sumarmatrices(n,m,x,y,z);
//mayor(n,m,x);
//vectoruno(m,n,x);
//vectordos(m,n,y);
vectortres(n,m,x);
vectorcuatro(n,m,x);
// encotrar el minimo de vector tres y el maximo de vector cuatro y si son iguales
//existe el punto de silla de montar
}
private static void vectorcuatro(double n, double m, double[][] x) {
double menor=x[1][1];
double w[]=new double [20];
double guardar=0;
for (int i=1; i<=m; i++){
menor=x[1][i];
for (int j=1; j<=n; j++){
if (menor>x[j][i]){
menor=x[j][i];
w[i]=menor;
}
else {
w[i]=menor;
}
}
}
for (int k=1; k<=m; k++){
System.out.println(w[k]);
}
}
private static void vectortres(double n, double m, double[][] x) {
double mayor=x[1][1];
double menor=x[1][1];
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
if (mayor <x[i][j]){
mayor=x[i][j];
z[i]=mayor;
}
}
mayor=0;
}
for (int k=1; k<=n; k++){
System.out.println(z[k]);
}
}
private static void mayor(double n, double m, double[][] x) {
int fila = 1,columna=1;
double mayor=x[1][1];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
if (mayor<x[i][j]){
mayor=x[i][j];
fila=i;
columna=j;
}
}
}
System.out.println("el mayor es: "+mayor+" esta en la fila "+fila+" y en la columna "+columna);
}
private static void vectordos(double m, double n, double[][] y) {
double sumafila=0;
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
sumafila=sumafila+y[i][j];
}z[i]=sumafila;
sumafila=0;
}for (int k=1; k<=n; k++){
System.out.print(" "+z[k]);
}
}
private static void vectoruno(double m, double n, double[][] x) {
double sumafila=0;
double z[]=new double[20];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++){
sumafila=sumafila+x[i][j];
}z[i]=sumafila;
sumafila=0;
}for (int k=1; k<=n; k++){
System.out.print(" "+z[k]);
}System.out.println("");
}
private static void sumarmatrices(double n, double m, double[][] x, double[][] y, double[][] z) {
System.out.println("\t");
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
z[i][j]=x[i][j]+y[i][j];
System.out.print(" "+z[i][j]);
}
System.out.println("\t");
}
}
private static void imprimirmatriz(double n, double m, double[][] x) {
System.out.println("\n");
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
System.out.print(" "+x[i][j]);
}
System.out.println("\t");
}
}
private static void leermatriz(double n, double m, double[][] x) {
Scanner lea= new Scanner(System.in);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
x[i][j]=lea.nextDouble();
}
}
}
}
Comentarios
Publicar un comentario