谈资

Talk

358B BY lydia_2020 @ 2020-03-20 22:21:38 IN Problem 1060

#include<stdio.h>
#include<iostream>
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		int fn3 = 0;
		if (n <= 0) {
			fn3 = 0;
		}
		else if (n <= 2) {
			fn3 = 1;
		}
		else {
			int fn1 = 1;
			int fn2 = 1;
			for (int i = 3; i <= n; i++) {
				fn3 = fn1 + fn2;
				fn1 = fn2;
				fn2 = fn3;
			}

		}
		cout << fn3 << endl;
	}
	return 0;
}
Tips:本主题暂无回复。
登录OnlineJudge账号后可以发表和回复Talk~登录OnlineJudge
请点击右方按钮跳转至OnlineJudge登录页面。