Created
August 25, 2011 00:37
-
-
Save yuripiratello/1169667 to your computer and use it in GitHub Desktop.
Tentando C++
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
/* | |
Codigo de definicao: fibonaci.h | |
*/ | |
#ifndef FIBONACI_H | |
#define FIBONACI_H | |
class Fibonaci{ | |
public: | |
void Fibonaci(); | |
void proximo(); | |
void reiniciar(); | |
int valorAtual; | |
int valorAnterior; | |
}; | |
void Fibonaci::Fibonaci(){ | |
this->valorAtual=1; | |
this->valorAnterior=0; | |
} | |
void Fibonaci::reiniciar(){ | |
this->valorAtual=1; | |
this->valorAnterior=0; | |
} | |
void Fibonaci::proximo(){ | |
printf(" %4.2d ", (this->valorAnterior + this->valorAtual)); | |
} |
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 "fibonaci.h" | |
using namespace std; | |
int main(int argc, char *argv[]) | |
{ | |
// declara um objeto da classe Fibonaci | |
Fibonaci f; | |
int i = 0; | |
printf("\nTemperatura atual: %4.2f",f.valorAtual); | |
// Fibonaci ate 25 | |
printf("\nFibonaci ate 25"); | |
printf("\n"); | |
for (i = 0; i <=25; i++){ | |
f.proximo(); | |
} | |
printf("\n"); | |
printf("\nReiniciando"); | |
f.reinicia(); | |
printf("\n"); | |
// Fibonaci ate 30 | |
printf("\nFibonaci ate 30"); | |
printf("\n"); | |
for (i = 0; i <=30; i++){ | |
f.proximo(); | |
} | |
printf("\n"); | |
printf("\n"); | |
system("PAUSE"); // pausa o programa | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment