CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 05:47:19 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=f352ecfa21cd0c10f9eea8ebb2c7dff825a8ca2a41d060b0f00fd0a7e1c6ae46a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%222iaksbdFly9yuwSmy4F4Fv38PQZ0sRdK%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d44d475e22ad8b-BLR
Lab1Challenge2CPP - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- std::cout <<
- "2. Найти n-ый член ряда Фибоначчи, элементы которого вычисляются по формулам: a1=a2=1; ai=ai-1 + ai-2, (i>2)."
- << std::endl << std::endl;
- int index;
- bool isWrong;
- int numbers[2];
- index = 0;
- isWrong = true;
- numbers[0] = 1, numbers[1] = 1;
- while (isWrong) {
- std::cout << "Номер члена из ряда Фибаначчи (не может быть меньше 3): ";
- std::cin >> index;
- if (std::cin.fail()) {
- std::cout << "Введите число, а не строку или что-то иное!" << std::endl;
- std::cin.clear();
- std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
- } else if (index < 3)
- std::cout << "Число должно быть не меньше 3!" << std::endl;
- else
- isWrong = false;
- }
- for (int i = 0; i < index - 2; i++) {
- if (numbers[0] < numbers[1])
- numbers[0] += numbers[1];
- else
- numbers[1] += numbers[0];
- }
- std::cout << index << "-ый член ряда: ";
- if (numbers[0] > numbers[1])
- std::cout << numbers[0] << std::endl;
- else
- std::cout << numbers[1] << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ A
JavaScript | 8 sec ago | 0.25 KB
-
⭐⭐⭐Free Giftcards Method⭐⭐
Java | 10 sec ago | 0.10 KB
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ L
JavaScript | 17 sec ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ H
JavaScript | 26 sec ago | 0.25 KB
-
⭐⭐⭐Exchange Exploit T 3⭐⭐
Java | 28 sec ago | 0.10 KB
-
📌 Swapzone +37% glitch ⭐ 5
JavaScript | 36 sec ago | 0.25 KB
-
⭐⭐⭐Swapzone.io Glitch (Working)⭐⭐
Java | 40 sec ago | 0.10 KB
-
✅⭐ Make huge profits on trading ⭐⭐ E
JavaScript | 45 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand