Skip to content

Instantly share code, notes, and snippets.

@yuripiratello
Created August 25, 2011 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuripiratello/1169667 to your computer and use it in GitHub Desktop.
Save yuripiratello/1169667 to your computer and use it in GitHub Desktop.
Tentando C++
/*
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));
}
#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