Created
August 15, 2011 19:09
-
-
Save carlossaraiva/1147478 to your computer and use it in GitHub Desktop.
Exercício 5 e 6 dado em sala.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import javax.swing.text.html.HTMLEditorKit.Parser; | |
public class principal { | |
public static void main (String args[]) | |
{ | |
int vetorA[][] = new int[10][10]; | |
int vetorB[][] = new int[10][10]; | |
int vetorR[][] = new int[10][10]; | |
int acumulador = 0; | |
int numeroBusca = 0; | |
Scanner leitura = new Scanner(System.in); | |
for (int i = 0; i <= 9; i++) | |
{ | |
for (int j = 0; j <= 9; j++) | |
{ | |
acumulador = acumulador + 2; | |
vetorA[i][j] = acumulador; | |
vetorB[i][j] = acumulador; | |
vetorR[i][j] = vetorA[i][j] + vetorB[i][j]; | |
} | |
} | |
System.out.println("Digite o número a ser buscado"); | |
numeroBusca = leitura.nextInt(); | |
int indLinFound = 0; | |
int indColFound = 0; | |
int achado = 0; | |
for (int i = 0; i <= 9; i++) | |
{ | |
for (int j = 0; j <= 9; j++) | |
{ | |
if(numeroBusca == vetorR[i][j]) | |
{ | |
achado = 1; | |
indLinFound = i; | |
indColFound = j; | |
} | |
} | |
} | |
if (achado == 1) | |
{ | |
System.out.println("O valor foi encontrado na matriz" + "R[" + indLinFound + "],[" + indColFound + "]"); | |
} | |
else | |
{ | |
System.out.println("O valor não foi encontrado!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment