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
# Realiza a soma de 0 a 999: | |
r = 0 | |
x = 1 | |
while x < 1000 : | |
r = r + x | |
x = x + 1 | |
print("A soma de 0 a 1000 é " + str(r)) |
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
while condicao : | |
# Faz alguma coisa | |
continue | |
break | |
else : | |
# Faz alguma coisa |
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
# Faz a soma de 0 a 999 | |
r = 0 | |
for x in range(0, 1000) : | |
r = r + x | |
print("A soma de 0 a 999 é " + str(r)) |
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
for referencia in sequencia : | |
# faz alguma coisa | |
continue | |
break | |
else : | |
# faz alguma coisa |
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
/** | |
* Função para formatar um número colocando pontos. | |
* @author Víctor Vaz <[email protected]> | |
* @param n Número para ser formatado. | |
* @returns {string} Número formatado. | |
*/ | |
function formatarNumero(n) { | |
var n = n.toString(); | |
var r = ''; | |
var x = 0; |
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
main = do | |
print "Oi mundo!"; |
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 datanojava; | |
public class UnixTime { | |
public static void main(String[] args) { | |
long unixTimeAtual = System.currentTimeMillis() / 1000L; | |
System.out.println(unixTimeAtual); | |
} | |
} |
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 datanojava; | |
import java.text.DateFormat; | |
import java.util.Calendar; | |
import java.util.Locale; | |
public class DatasInternacionais { | |
public static void main(String[] args) { | |
Calendar c = Calendar.getInstance(); |
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 datanojava; | |
import java.util.GregorianCalendar; | |
public class AnoBissexto { | |
public static void main (String[] args) { | |
GregorianCalendar gc = new GregorianCalendar(); | |
System.out.println(gc.isLeapYear(2015)); // false. Não é bissexto. | |
System.out.println(gc.isLeapYear(2016)); // true. É bissexto. | |
} |
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 datanojava; | |
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
public class AlterandoGregorianCalendar { | |
public static void main (String[] args) { | |
GregorianCalendar gc = new GregorianCalendar(); | |
gc.set(Calendar.YEAR, 1995); | |
gc.set(Calendar.MONTH, Calendar.AUGUST); |
NewerOlder