Created
March 13, 2017 02:19
-
-
Save joeldatabox/8efccaad97f70a7789caef211752177e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package br.ueg.programacaoi; | |
| import java.util.Scanner; | |
| public class Matriz { | |
| Scanner sc; | |
| int mat[][]; | |
| int matT[][]; | |
| public static void main(String[] args) { | |
| Matriz m = new Matriz(); | |
| m.sc = new Scanner(System.in); | |
| //m.mat = new int[][] | |
| System.out.println("Quantas colunas tera a matriz?"); | |
| int col = m.sc.nextInt(); | |
| System.out.println("Quantas linhas tera a matriz?"); | |
| int lin = m.sc.nextInt(); | |
| m.mat = new int[col][lin]; | |
| for (int i = 0; i < m.mat.length; i++) { | |
| for (int j = 0; j < m.mat[i].length; j++) { | |
| System.out.println("Informe o valor [" + (i+1) + "][" + (j+1) + "]"); | |
| m.mat[i][j] = m.sc.nextInt(); | |
| } | |
| System.out.println(""); | |
| } | |
| System.out.println("imprimindo a matriz"); | |
| m.imprimeMatriz(m.mat); | |
| System.out.println("fazendo a transposta "); | |
| m.matT = new int[lin][col]; | |
| for (int i = 0; i < m.mat.length; i++) { | |
| for (int j = 0; j < m.mat[i].length; j++) { | |
| m.matT[j][i] = m.mat[i][j]; | |
| } | |
| } | |
| System.out.println("imprimindo a matriz"); | |
| m.imprimeMatriz(m.matT); | |
| } | |
| void imprimeMatriz(int[][] mat){ | |
| for (int i = 0; i < mat.length; i++) { | |
| for (int j = 0; j < mat[i].length; j++) { | |
| System.out.print("|" + mat[i][j] + "|"); | |
| } | |
| System.out.println(""); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| package br.ueg.programacaoi; | |
| import java.util.Scanner; | |
| public class Triangulo { | |
| public static void main(String[] args) { | |
| Scanner sc= new Scanner(System.in); | |
| int a = 0; | |
| int b = 0; | |
| int c = 0; | |
| boolean a1= false; | |
| System.out.println("Qual o valor do lado A?"); | |
| a = sc.nextInt(); | |
| System.out.println("Qual o valor do lado B?"); | |
| b = sc.nextInt(); | |
| System.out.println("Qual o valor do lado C?"); | |
| c = sc.nextInt(); | |
| if((a > (b + c)) || (b > (c+a)) || (c > (a+b))){ | |
| System.out.println("As medidas informadas não forma um triangulo"); | |
| }else{ | |
| System.out.println("As medidas informadas forma um triangulo"); | |
| } | |
| } | |
| } |
This file contains hidden or 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
| package br.ueg.programacaoi; | |
| import java.util.Scanner; | |
| /** | |
| * | |
| * @author joel | |
| */ | |
| public class Vetor { | |
| int vet[]; | |
| String vetString[]; | |
| double mat[][]; | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| Vetor v = new Vetor(); | |
| v.vet = new int[]{10, 11, 12, 13, 14, 15}; | |
| for (int i = 0; i < v.vet.length; i++) { | |
| System.out.println("vetor[" + i + "] = " + v.vet[i]); | |
| } | |
| v.vetString = new String[10]; | |
| v.vetString = new String[11]; | |
| v.mat = new double[5][5]; | |
| for(int i = 0; i < v.mat.length; i++ ){ | |
| for(int j = 0; j < v.mat[i].length; j++){ | |
| v.mat[i][j] = i * j; | |
| } | |
| } | |
| for(int i = 0; i < v.mat.length; i++ ){ | |
| for(int j = 0; j < v.mat[i].length; j++){ | |
| System.out.print("|" + v.mat[i][j] + "|"); | |
| } | |
| System.out.println(""); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment