OOP HomeWork
This commit is contained in:
14
oop_hw1/oop_hw1_7/fib.cpp
Normal file
14
oop_hw1/oop_hw1_7/fib.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
long& smaller(long& a, long& b) { return (a < b) ? a : b; }
|
||||
long& bigger(long& a, long& b) { return (a >= b) ? a : b; }
|
||||
|
||||
void fibe(int count) {
|
||||
long a = 1, b = 1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
long& min = smaller(a, b);
|
||||
long& max = bigger(a, b);
|
||||
min = a + b;
|
||||
std::cout << max << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
9
oop_hw1/oop_hw1_7/fib.h
Normal file
9
oop_hw1/oop_hw1_7/fib.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#ifndef fib
|
||||
#define fib
|
||||
|
||||
long& smaller(long& a, long& b);
|
||||
long& bigger(long& a, long& b);
|
||||
void fibe(int count);
|
||||
|
||||
#endif // !fib
|
10
oop_hw1/oop_hw1_7/main.cpp
Normal file
10
oop_hw1/oop_hw1_7/main.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <iostream>
|
||||
#include "fib.h"
|
||||
|
||||
using namespace std;
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
fibe(n);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user