Last active
October 29, 2016 20:10
-
-
Save jorgejr568/042d30c1026d2379cd2c9731c0db7ae8 to your computer and use it in GitHub Desktop.
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 <locale.h> | |
using namespace std; | |
int main(){ | |
int qtd,n1=1,n2=1,i=0,tmp; | |
setlocale(LC_ALL,"Portuguese"); | |
cout << "Digite a quantidade da sequência: "; | |
cin >> qtd; | |
if(qtd>0){ | |
cout << 1; | |
if(qtd>1){ | |
cout << ",1"; | |
} | |
qtd-=2; | |
while(qtd>i){ | |
cout << "," << (n2+n1); | |
tmp=n1; | |
n1=(n2+n1); | |
n2=tmp; | |
i++; | |
} | |
} | |
else{ | |
cout << "Quantidade inválida"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment