DevioLab CRYPTO TRADING AUTOMATION
LIVE
AUTOMATED CRYPTO TRADING • BINANCE
Автоматизуйте свій криптопортфель
Торгові боти DevioLab аналізують крипторинок, автоматично відкривають і закривають позиції та керують вашим портфелем на Binance 24/7.
CRYPTO 80 Bots
BINANCE Spot Trading
TRADING 24 / 7
Спробувати DevioLab
deviolab.com

Інформація про навчальний заклад

ВУЗ:
Національний університет Львівська політехніка
Інститут:
Не вказано
Факультет:
КН
Кафедра:
Не вказано

Інформація про роботу

Рік:
2013
Тип роботи:
Звіт до лабораторної роботи
Предмет:
Програмування

Частина тексту файла (без зображень, графіків і формул):

Міністерство освіти та науки України Національний університет «Львівська політехніка» / ЗВІТ З лабораторної роботи №4-5 З дисципліни: «Програмування ч.4» Мета: 3) Вивести послідовності довжини K з чисел 1..N, внісши зміни в алгоритм Блок-схема: Лістинг програми: /****************************************************************\ FILE..........: programming_labs.h AUTHOR........: Taras Kobernyk DESCRIPTION...: The header file contains programming_labs. METHOD........: CFactorial, show_result FUNCTIONS.....: factorial SWITCHES......: WIN32 - if defined, 32-bit version is compiled, otherwise 16-bit edition is compiled. COPYRIGHT.....: Copyright (c) 2010. HISTORY.......: DATE COMMENT -------- -------------------------------------- - 03-17-10 Created - Taras 03-23-10 Modifid - Taras \****************************************************************/ … /****************************************************************\ CLASS…......: CSequence. DESCRIPTION…: Show all sequences of length k of the numbers 1 .. n. \****************************************************************/ class CSequence { private: int m_iN, m_iM; //Max numbers and length of Sequence int* m_piArr; //Array of Sequences public: CSequence(int iN, int iM); void Generate(int iK); }; /****************************************************************\ FUNCTION......: Generate DESCRIPTION...: Show all sequences of length k of the numbers 1 .. n ATTRIBUTES....: Public ARGUMENTS.....: iK - Condition exit function iN - number iM - length iArr - Array for storing sequences RETURNS.......: void \****************************************************************/ void Generate(int k, int n, int m, int* x); /** (END OF FILE : programming_labs.h)*********************************/ /****************************************************************\ FILE..........: programming_labs.cpp AUTHOR........: Taras Kobernyk DESCRIPTION...: Laboratory work, designed to solve common problems METHOD........: CFactorial, show_result FUNCTIONS.....: factorial SWITCHES......: WIN32 - if defined, 32-bit version is compiled, otherwise 16-bit edition is compiled. COPYRIGHT.....: Copyright (c) 2010, KI-21. HISTORY.......: DATE COMMENT -------- -------------------------------------- - 03-17-10 Created - Taras 03-23-10 Modified - Taras \****************************************************************/ /*===============================[ PUBLIC DECLARATIONS ]========*/ #include <iostream> #include <conio.h> #include "programming_labs.h" using namespace std; int main () { CSequence* sequence; // pointer by CSequence … case 3: /*===============================[ LABA #3 ]====================*/ int iM; int* iArr; cout << endl; cout << "\t\t\t\tLaboratory work #3" << endl; cout << endl; cout << "Select a method of program\n\t" "1 - Object-oriented method\n\t" "2 - Procedure-oriented method" << endl; iNumber_method = getch() - 48; switch(iNumber_method) { /*===============================[ OBJECT-ORIENTED METHOD ]======*/ case 1: cout << endl; cout << "\t\t\t\tObject-oriented method" << endl; cout << endl; cout << "n = "; cin >> iN; cout << "m = "; cin >> iM; sequence = new CSequence(iN,iM); sequence->Generate(0); break; /*===============================[ PROCEDURE-ORIENTED METHOD ]==*/ case 2: cout << endl; cout << "\t\t\tProcedure-oriented method" << endl; cout << endl; cout << "n = "; cin >> iN; cout << "m = "; cin >> iM; iArr = new int[iM]; Generate(0, iN, iM, iArr); break; } break; /*===============================[ END LABA #3 ]================*/ … /*===============================[ LABA #3 ]===================*/ /****************************************************************\ METHOD........: CSequence DESCRIPTION...: Initializing variables ATTRIBUTES....: Public ARGUMENTS.....: None RETURNS.......: void \****************************************************************/ CSequence::CSequence(int iN, int iM) { m_iN = iN; //Max numbers of Sequence m_iM = iM; //lendth of Sequences m_piArr = new int[iM]; //Array of Sequences } /****************************************************************\ METHOD........: Generate DESCRIPTION...: Show all sequences of length k of the numbers 1 .. n ATTRIBUTES....: Public ARGUMENTS.....: iK - Condition exit function RETURNS.......: void \****************************************************************/ void CSequence::Generate(int iK) { /*Recursive function for the output sequence of length K with the numbers 1 .. N*/ if (iK==m_iM) { for (int i=1;i<=m_iM;i++) cout << m_piArr[i]; cout << endl; } else for (int j=1;j<=m_iN;j++) { m_piArr[iK+1]=j; Generate(iK+1); } } /****************************************************************\ FUNCTION......: Generate DESCRIPTION...: Show all sequences of length k of the numbers 1 .. n ATTRIBUTES....: Public ARGUMENTS.....: iK - Condition exit function iN - number iM - length iArr - Array for storing sequences RETURNS.......: void \****************************************************************/ void Generate(int iK, int iN, int iM, int* iArr) { /*Recursive function for the output sequence of length K with the numbers 1 .. N*/ if (iK==iM) { for (int i=1;i<=iM;i++) cout << iArr[i]; cout << endl; } else for (int j=1;j<=iN;j++) { iArr[iK+1]=j; Generate(iK+1, iN, iM, iArr); } } Висновок: /
Антиботан аватар за замовчуванням

06.03.2013 23:53

Коментарі

Ви не можете залишити коментар. Для цього, будь ласка, увійдіть або зареєструйтесь.

Ділись своїми роботами та отримуй миттєві бонуси!

Нічого не вибрано
0%

Оголошення від адміністратора

Антиботан аватар за замовчуванням

Подякувати Студентському архіву довільною сумою

Admin

26.02.2023 12:38

Дякуємо, що користуєтесь нашим архівом!