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
#include <stdio.h> | |
struct pessoa | |
{ | |
int idade; | |
}; | |
typedef float real; | |
typedef struct pessoa tipo_pessoa; |
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
#include <stdio.h> | |
#include <stdlib.h> // contém funções como malloc, realloc, free, exit | |
#define MAX 5 // quantidade para ser alocada | |
int main() | |
{ | |
int *vet; // variável ponteiro do tipo inteiro | |
int i = 0, qte = 0; | |
// aloca um espaço para MAX números inteiros |
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
#include <stdio.h> | |
void trocar(int *a, int *b) | |
{ | |
*a = *a ^ *b; | |
*b = *a ^ *b; | |
*a = *a ^ *b; | |
printf("%d %d\n", *a, *b); | |
} |
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
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
// cria uma string | |
string str("Hello"); |
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
#include <stdio.h> | |
int russian_peasant(unsigned int x, unsigned int y) | |
{ | |
int resultado = 0; | |
while(y > 0) | |
{ | |
if(y % 2 != 0) | |
resultado += x; |
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
// Game Guess the Number | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int main() | |
{ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JavaScript</title> | |
</head> | |
<body> | |
<script> | |
// função que retorna a soma de dois números |
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
function fib(n) { | |
if(n == 1 || n == 2) { | |
return 1; | |
} | |
return fib(n-1) + fib(n-2); | |
} | |
console.log(fib(10)); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JavaScript</title> | |
</head> | |
<body> | |
<script> | |
// criando um array | |
var vetor = [1, 2, 3, 4]; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JavaScript</title> | |
</head> | |
<body> | |
<script> | |
// criando um objeto | |
var pessoa = new Object(); |