diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..220c1a3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +STEP1_Basics/*/a.out diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..acdd8ae --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "STEP1_Basics/3_Formatting/c_cross_pack"] + path = STEP1_Basics/3_Formatting/c_cross_pack + url = ssh://git@git.del.pw:2222/justuser-31/c_cross_pack.git diff --git a/STEP1_Basics/1_Hello_world/main.c b/STEP1_Basics/1_Hello_world/main.c new file mode 100644 index 0000000..f63f331 --- /dev/null +++ b/STEP1_Basics/1_Hello_world/main.c @@ -0,0 +1,7 @@ +#include + +int main() { + printf("Hello world\n"); + + return 0; +} diff --git a/STEP1_Basics/2_Arithmetic/main.c b/STEP1_Basics/2_Arithmetic/main.c new file mode 100644 index 0000000..a836d84 --- /dev/null +++ b/STEP1_Basics/2_Arithmetic/main.c @@ -0,0 +1,26 @@ +#include +#include + +int main() { + float x, y; + printf("Enter x: "); scanf("%f", &x); + printf("Enter y: "); scanf("%f", &y); + + float sum = x + y; + float sub = x - y; + float mult = x * y; + float div = x / y; + float poww = pow(x, y); + float sqrtt = pow(x, (1/y)); + + printf("Results:\n" + "sum: %f\n" + "sub: %f\n" + "mult: %f\n" + "div: %f\n" + "pow: %f\n" + "sqrt: %f\n", + sum, sub, mult, div, poww, sqrtt); + + return 0; +} diff --git a/STEP1_Basics/3_Formatting/c_cross_pack b/STEP1_Basics/3_Formatting/c_cross_pack new file mode 160000 index 0000000..f9a5352 --- /dev/null +++ b/STEP1_Basics/3_Formatting/c_cross_pack @@ -0,0 +1 @@ +Subproject commit f9a5352b6e6752375cd3520b28da474285288768 diff --git a/STEP1_Basics/3_Formatting/main.c b/STEP1_Basics/3_Formatting/main.c new file mode 100644 index 0000000..25acfda --- /dev/null +++ b/STEP1_Basics/3_Formatting/main.c @@ -0,0 +1,35 @@ +#include +#include + +#include "c_cross_pack/libs/string.h" + +int main() { + int day, year; + string month = strInit(""); + + printf("Enter day of month: "); scanf("%d", &day); + printf("Enter month name: "); scanf("%s", month); + printf("Enter year: "); scanf("%d", &year); + + string yyyy_mm_dd = strInit(int2Str(&year)); + strAdd(&yyyy_mm_dd, "-"); + strAdd(&yyyy_mm_dd, month); + strAdd(&yyyy_mm_dd, "-"); + strAdd(&yyyy_mm_dd, int2Str(&day)); + + string dd_mm_yyyy = strInit(int2Str(&day)); + strAdd(&dd_mm_yyyy, "-"); + strAdd(&dd_mm_yyyy, month); + strAdd(&dd_mm_yyyy, "-"); + strAdd(&dd_mm_yyyy, int2Str(&year)); + + printf("\nResult:\n"); + printf("yyyy_mm_dd: %s\n", yyyy_mm_dd); + printf("dd_mm_yyyy: %s\n", yyyy_mm_dd); + + free(month); + + return 0; +} + +