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 #131

Open
wants to merge 2 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
8 changes: 8 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework1/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>

int main()
{
int a;
std::cin >> a;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это не функция

std::cout << a * a;
}
9 changes: 9 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework1/2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>

int main()
{
int a, b, h;
std::cin >> a >> b >> h;
std::cout << (b + a) * h / 2.0;
return 0;
}
16 changes: 16 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework1/3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>

int main() {
int a;
std::cin >> a;
int b[10000];
b[0] = 0;
b[1] = 1;
for (int i = 0; i < a; i++) {
if (i >= 2) {
b[i] = b[i - 1] + b[i - 2];
}
std::cout << b[i] << " ";
}
return 0;
}
20 changes: 20 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework1/4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>

int main()
{
int a, b = 0, i = 1, j = 1, c;
std::cin >> a;
c = a;
c /= 10;
while(c > 0){
c /= 10;
j*=10;
}
while (a > 0) {
b += i*(a / j);
a %= j;
j /= 10;
i *= 10;
}
std::cout << b;
}
38 changes: 38 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework2/1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <string>

int main()
{
int num;
std::string eight, sixteen = "";
std::cout << "Enter number to convert in eight and sixteen system: ";
std::cin >> num;
for (int x = num; x > 0;) {
eight = std::to_string(x % 8) + eight;
x /= 8;
}
for (int x = num; x > 0;) {
if (x % 16 > 9) {
switch (x % 16) {
case 10:
sixteen += "A";
case 11:
sixteen += "B";
case 12:
sixteen += "C";
case 13:
sixteen += "D";
case 14:
sixteen += "E";
case 15:
sixteen += "F";
}
}
else {
sixteen = std::to_string(x % 16) + sixteen;
}
x /= 16;
}
std::cout << "Your number in eight system: " << eight << std::endl << "Your number in sixteen system: " << sixteen;
return 0;
}
17 changes: 17 additions & 0 deletions sem1/TimofeiShirobokih/MiniHomework2/2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>

int main()
{
int num;
std::cout << "Enter number to use it on Syracuse hypothesis: ";
std::cin >> num;
while (num != 1) {
if ((num % 2) == 1) {
num = num * 3 + 1;
}
num /= 2;
std::cout << "Current number: " << num << std::endl;
}
std::cout << "Hypothesis is correct";
return 0;
}