Skip to content

Commit a6660d9

Browse files
25.12.2022 12:36
Signed-off-by: Vladimir Tolstov <vladimir.tolstov@selfip.ru>
1 parent 6583cdc commit a6660d9

File tree

5 files changed

+76
-83
lines changed

5 files changed

+76
-83
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
make: clean build run
2+
13
build:
24
mkdir build
3-
g++ datatypes.cpp example.cpp -o build/example.out
5+
g++ src/datatypes.cpp examples/example.cpp -o build/example.out
6+
@echo "build: ok"
7+
8+
clean:
9+
rm -fr build/
10+
@echo "ok"
11+
12+
run:
13+
@echo "run: ok"
14+
build/example.out

datatypes.cpp

Lines changed: 0 additions & 70 deletions
This file was deleted.

example.cpp renamed to examples/example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "datatypes.h"
1+
#include "../src/datatypes.h"
22
#include <iostream>
33

44
int main()

src/datatypes.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "datatypes.h"
2+
#include <iostream>
3+
4+
using namespace DataTypes;
5+
6+
Pair::Pair(int a = 0, int b = 0)
7+
{
8+
match.x = a;
9+
match.y = b;
10+
};
11+
12+
pair Pair::get()
13+
{
14+
return match;
15+
};
16+
17+
void Pair::set(int a = 0, int b = 0)
18+
{
19+
match.x = a;
20+
match.y = b;
21+
};
22+
23+
int Pair::sum()
24+
{
25+
return match.x + match.y;
26+
};
27+
28+
int Pair::fminuss()
29+
{
30+
return match.x - match.y;
31+
};
32+
33+
int Pair::sminusf()
34+
{
35+
return match.y - match.x;
36+
};
37+
38+
int Pair::multi()
39+
{
40+
return match.x * match.y;
41+
};
42+
43+
int Pair::fdivides()
44+
{
45+
return match.x / match.y;
46+
};
47+
48+
int Pair::sdividef()
49+
{
50+
return match.y / match.x;
51+
};
52+
53+
int Pair::power()
54+
{
55+
int result = 1;
56+
57+
for (int i = 0; i < match.y; i++)
58+
{
59+
result *= match.x;
60+
}
61+
62+
return result;
63+
};

datatypes.h renamed to src/datatypes.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,26 @@
33

44
namespace DataTypes
55
{
6-
76
struct pair
87
{
98
int x;
109
int y;
1110
};
12-
1311
class Pair
1412
{
1513
private:
1614
pair match;
1715

1816
public:
1917
Pair(int a, int b);
20-
2118
pair get();
22-
2319
void set(int a, int b);
24-
2520
int sum();
26-
2721
int fminuss();
28-
2922
int sminusf();
30-
3123
int multi();
32-
3324
int fdivides();
34-
3525
int sdividef();
36-
3726
int power();
3827
};
3928
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy