언어/C++
[ C++ ] 피보나치수열
power-girl0-0
2021. 6. 2. 05:22
728x90
소스코드
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
queue <int> q;
int num;
q.push(0); q.push(1);
cout<<endl;
cout<<q.front()<<" ";
for(int i=0; i<20; i++){
num = q.front() + q.back();
cout<<q.back()<<" ";
q.pop();
q.push(num);
}
cout<<endl;
}
결과
728x90