Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minihomework2 #256

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sem1/NovikovAM/MiniHomeWork1/Task1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

#include <iostream>

int quadro(int a);

int main()
{
int a;
std::cout << "Input side: \n";
std::cin >> a;
std::cout << "S = " << quadro(a);
return 0;
}

int quadro(int a) {
return a * a;
}
19 changes: 19 additions & 0 deletions sem1/NovikovAM/MiniHomeWork1/Task2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>

int trapeze(int a, int b, int h);

int main() {
int a, b, h;
std::cout << "Input up side: \n";
std::cin >> a;
std::cout << "Input down side: \n";
std::cin >> b;
std::cout << "Input height: \n";
std::cin >> h;
std::cout << trapeze(a, b, h);
return 0;
}

int trapeze(int a, int b, int h) {
return ((a + b) / 2) * h;
}
16 changes: 16 additions & 0 deletions sem1/NovikovAM/MiniHomeWork1/Task3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>

int main() {
int a = 0, b = 1, l = 0, c = 0;
std::cout << "Input number cicle: ";
std::cin >> l;
std::cout << 1 << " ";
for (int i = l; i > 0; --i) {
c = a + b;
a = b;
b = c;

std::cout << c << " ";
}

}
14 changes: 14 additions & 0 deletions sem1/NovikovAM/MiniHomeWork1/Task4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <iostream>

int main() {
int g;
std::cout << "Input your number: ";
std::cin >> g;



while (g != 0) {
std::cout << g%10;
g /= 10;
}
}
43 changes: 43 additions & 0 deletions sem1/NovikovAM/MiniHomeWork2/Task1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <iostream>

std::string RevertToHexToOct(int Dec, std::string tableSym) {
std::string HexOctNum;
while (Dec > 0) {
HexOctNum = tableSym[Dec%tableSym.length()] + HexOctNum;
Dec = Dec /tableSym.length();
}
return HexOctNum;
}


int main() {
std::string OctTable = "01234567";
std::string HexTable = "0123456789ABCDEF";

bool Exit = true;

int Choiсe;
int Dec;

while (Exit){
std::cout << "Enter choice revert(1 - Hex, 2 - Oct, 0 - Exit): ";
std::cin >> Choiсe;
std::cout << "Enter your Dec number: " << std::endl;
std::cin >> Dec;
switch (Choiсe) {
case 1:
std::cout<< "Your Hex number: " << RevertToHexToOct(Dec,HexTable) << std::endl;

break;
case 2:
std::cout<< "Your Oct number: " << RevertToHexToOct(Dec,OctTable) << std::endl;
break;
case 0:
Exit = false;
break;
default:
std::cout << "Invalid Choice";
break;
}
}
}
38 changes: 38 additions & 0 deletions sem1/NovikovAM/MiniHomeWork2/Task2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Task2.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//

#include <iostream>


class Task2
{
int InputNum;
int supposed1;
public:
Task2(int suppoused1) {
supposed1 = suppoused1;

}

int Sirakuz(int supposed1) {
while (supposed1 != 1 and supposed1 != 0) {
if (supposed1 % 2 == 0) {
supposed1 = supposed1 / 2;
}
else {
supposed1 = ((supposed1 * 3) + 1) / 2;
};
}
return supposed1;
}

};

int main() {
int input;
std::cout << "Enter number: ";
std::cin >> input;

Task2 dsda(input);
std::cout << dsda.Sirakuz(input);
}
94 changes: 94 additions & 0 deletions sem1/NovikovAM/Project1/.idea/workspace.xml
Cauua123 marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.