Skip to content

Instantly share code, notes, and snippets.

View gmfc's full-sized avatar
🏠
Working from home

Gabriel Melo Correia gmfc

🏠
Working from home
View GitHub Profile
@gmfc
gmfc / file.rb
Created May 8, 2013 22:03
Gist criando pelo Android
puts 'ola mundo'
class programa{
public static void main(String args[]){
System.out.println("Olá mundo");
}
}
@gmfc
gmfc / sqrt.java
Created May 9, 2013 11:15
Metodo de Newton para raiz quadrada.
import java.util.*;
class prog{
public static void main(String [] args){
double xa,n,eps,xn;
Scanner s = new Scanner(System.in);
xa = s.nextDouble();
n = s.nextDouble();
eps = s.nextDouble();
xn = xa - (xa*xa-n)/(2*xa);
@gmfc
gmfc / proc.java
Created May 13, 2013 14:44
Procedimentos_métodos
class exemplo{
static double atributo1; //atributos da classe
public static void main(Strings args[]){
//main
}
public static void procedimento(){
//procedimento
}
}
import javax.swing.*;
public class calculadora {
static double x,y,resultado;
static int opcao;
public static void soma(){
resultado = x+y;
}
import javax.swing.*;
import java.lang.*;
class seno{
public static void main(String args[]){
double x, soma=0,fat,xgraus;
int n;
x = Double.parseDouble(JOptionPane.showInputDialog("Insira o angulo (em graus)"));
@gmfc
gmfc / fatorial.java
Created May 16, 2013 11:05
Função que calcula fatorial
clss fatorial{
public static void main(String args[]){
System.out.println(fat(10));
}
public static double fat(double n){
n==0?1:n*fat(n-1);
return n;
}
}
public int mdc( int x, int y ){
if(x == y){
return x;
}
else if( y > x ){
return mdc( x, y-x );
}
else if( x > y ){
return mdc( x - y, y );
}
import javax.swing.*;
class maior{
public static void main(String args[]){
int a,b;
a = Integer.parseInt(JOptionPane.showInputDialog("Entre com o 1° número"));
b = Integer.parseInt(JOptionPane.showInputDialog("Entre com o 2° número"));
JOptionPane.showMessageDialog(null,"O maior dentre os 2 é: "+devmaior(a,b));
}
public static int devmaior(int a, int b){
@gmfc
gmfc / vetores.java
Last active December 17, 2015 14:59
Aula 22. Em construção... EDIT completo
import javax.swing.*;
class vetores{
public static void main(String [] args){
int[] vetor;
int tamanho,x,iPosicao;
do{
tamanho = Integer.parseInt(JOptionPane.showInputDialog("Entre com o tamanho do vetor"));
}while(tamanho<=0);