Last active
March 27, 2018 14:36
-
-
Save gabfssilva/7959a36f1c24cedb938cb7d016e9f937 to your computer and use it in GitHub Desktop.
ex_for_while
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
import java.time.LocalDateTime; | |
import java.util.Scanner; | |
/** | |
* int/Integer i = 2000 + 2556 = 45.56; | |
* short/Short sh = 20; | |
* long/Long l = 20; | |
* boolean/Boolean = true/false; | |
* String = "texto" | |
* char/Char = 'c' | |
* byte/Byte = 127 | |
* float/Float = 25.4f | |
* double/Double = 35.5 | |
* BigDecimal = new BigDecimal(20.00) | |
* Date = new Date() | |
* Calendar = Calendar.getInstance(); | |
* LocalDate | |
* LocalDateTime | |
* ZonedDateTime / -0300 | |
* | |
* @author Gabriel Francisco - [email protected] | |
*/ | |
class Being { | |
public void walk(){} | |
public void eat(){} | |
} | |
class Person extends Being { | |
public void speak(){} | |
} | |
class Pet extends Being { | |
public void bePet(){} | |
} | |
class Dog extends Pet { | |
public void bark(){} | |
} | |
class Cat extends Pet { | |
public void meow(){} | |
} | |
public class helloworld { | |
public static void main(String[] args) { | |
Person p = new Person(); | |
p.eat(); | |
Scanner scanner = new Scanner(System.in); | |
int tamanho = 5; | |
int[] v = new int[tamanho]; | |
for (int i = 0; i < tamanho; i = i + 1) { | |
int valor = scanner.nextInt(); | |
v[i] = valor; | |
} | |
int ppk = 0; | |
for (int i = 0; i < tamanho; i = i + 1){ | |
ppk = ppk + v[i]; | |
} | |
System.out.println(ppk); | |
} | |
} | |
import java.util.Scanner; | |
public class fib { | |
public static void main(String[] args) { | |
Scanner s = new Scanner(System.in); | |
for (int i = 0; i <= 50; i++) { | |
System.out.print(fib(i) + " "); | |
} | |
} | |
public static int fib(int n) { | |
if (n == 0) { | |
return 0; | |
} | |
if (n == 1 || n == 2) { | |
return 1; | |
} | |
return fib(n - 1) + fib(n - 2); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment