diff --git a/2025.02.14/01Ex/Makefile b/2025.02.14/01Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/01Ex/Makefile +++ b/2025.02.14/01Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.14/02Ex/Makefile b/2025.02.14/02Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/02Ex/Makefile +++ b/2025.02.14/02Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.14/03Ex/Makefile b/2025.02.14/03Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/03Ex/Makefile +++ b/2025.02.14/03Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.14/04Ex/Makefile b/2025.02.14/04Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/04Ex/Makefile +++ b/2025.02.14/04Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.14/06Ex/Makefile b/2025.02.14/06Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/06Ex/Makefile +++ b/2025.02.14/06Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.14/07Ex/Makefile b/2025.02.14/07Ex/Makefile index 75cb2c0..3f7fab7 100644 --- a/2025.02.14/07Ex/Makefile +++ b/2025.02.14/07Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a07.exe: main.o solve.o - gcc main.o solve.o -o a07.exe -lssp +a07.out: main.o solve.o + gcc main.o solve.o -o a07.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -10,4 +10,4 @@ solve.o: solve.c gcc $(FLAGS) -c solve.c clean: - del *.o *.exe \ No newline at end of file + rm *.o *.out \ No newline at end of file diff --git a/2025.02.14/08Ex/Makefile b/2025.02.14/08Ex/Makefile index 5832fda..e544ca6 100644 --- a/2025.02.14/08Ex/Makefile +++ b/2025.02.14/08Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o solve.o - gcc main.o solve.o -o a08.exe -lssp +a08.out: main.o solve.o + gcc main.o solve.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -10,4 +10,4 @@ solve.o: solve.c gcc $(FLAGS) -c solve.c clean: - del *.o *.exe \ No newline at end of file + rm *.o *.out \ No newline at end of file diff --git a/2025.02.14/09Ex/Makefile b/2025.02.14/09Ex/Makefile index 669b997..4cf96a5 100644 --- a/2025.02.14/09Ex/Makefile +++ b/2025.02.14/09Ex/Makefile @@ -29,7 +29,7 @@ CFLAGS = -mfpmath=sse \ -c all: main.o array.o - gcc main.o array.o -lssp && del *.o + gcc main.o array.o && rm *.o main.o: main.c gcc $(CFLAGS) main.c diff --git a/2025.02.21/01Ex/Makefile b/2025.02.21/01Ex/Makefile index 11a8ad1..eb08a91 100644 --- a/2025.02.21/01Ex/Makefile +++ b/2025.02.21/01Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a01.exe -lssp +a01.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe \ No newline at end of file + rm *.o *.out \ No newline at end of file diff --git a/2025.02.21/02Ex/Makefile b/2025.02.21/02Ex/Makefile index b4136a4..b995b72 100644 --- a/2025.02.21/02Ex/Makefile +++ b/2025.02.21/02Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a02.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a02.exe -lssp +a02.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a02.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/03Ex/Makefile b/2025.02.21/03Ex/Makefile index 742a071..3f80b94 100644 --- a/2025.02.21/03Ex/Makefile +++ b/2025.02.21/03Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a03.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a03.exe -lssp +a03.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a03.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/04Ex/Makefile b/2025.02.21/04Ex/Makefile index b93020e..abae3ea 100644 --- a/2025.02.21/04Ex/Makefile +++ b/2025.02.21/04Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a04.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a04.exe -lssp +a04.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a04.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/05Ex/Makefile b/2025.02.21/05Ex/Makefile index c40ed58..5848b3c 100644 --- a/2025.02.21/05Ex/Makefile +++ b/2025.02.21/05Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a05.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a05.exe -lssp +a05.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a05.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/06Ex/Makefile b/2025.02.21/06Ex/Makefile index aef2b70..da96092 100644 --- a/2025.02.21/06Ex/Makefile +++ b/2025.02.21/06Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a06.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a06.exe -lssp +a06.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a06.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/07Ex/Makefile b/2025.02.21/07Ex/Makefile index 90aeeae..218d03a 100644 --- a/2025.02.21/07Ex/Makefile +++ b/2025.02.21/07Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a07.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a07.exe -lssp +a07.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a07.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.21/08Ex/Makefile b/2025.02.21/08Ex/Makefile index 6d0657c..4208e7d 100644 --- a/2025.02.21/08Ex/Makefile +++ b/2025.02.21/08Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o array.o solve.o - gcc main.o solve.o array.o -o a08.exe -lssp +a08.out: main.o array.o solve.o + gcc main.o solve.o array.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -13,4 +13,4 @@ array.o: array.c gcc $(CFLAGS) -c array.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/01Ex/Makefile b/2025.02.28/01Ex/Makefile index 859dbc6..95dbbf2 100644 --- a/2025.02.28/01Ex/Makefile +++ b/2025.02.28/01Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a01.exe -lssp +a01.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/02Ex/Makefile b/2025.02.28/02Ex/Makefile index ebc13fc..c101a1f 100644 --- a/2025.02.28/02Ex/Makefile +++ b/2025.02.28/02Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a02.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a02.exe -lssp +a02.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a02.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/03Ex/Makefile b/2025.02.28/03Ex/Makefile index 1bff8fe..b4a1172 100644 --- a/2025.02.28/03Ex/Makefile +++ b/2025.02.28/03Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a03.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a03.exe -lssp +a03.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a03.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/04Ex/Makefile b/2025.02.28/04Ex/Makefile index 217960a..41fb685 100644 --- a/2025.02.28/04Ex/Makefile +++ b/2025.02.28/04Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a04.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a04.exe -lssp +a04.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a04.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/05Ex/Makefile b/2025.02.28/05Ex/Makefile index b01b1b5..a84b1d7 100644 --- a/2025.02.28/05Ex/Makefile +++ b/2025.02.28/05Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a05.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a05.exe -lssp +a05.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a05.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/06Ex/Makefile b/2025.02.28/06Ex/Makefile index a156fa5..a8acc0c 100644 --- a/2025.02.28/06Ex/Makefile +++ b/2025.02.28/06Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a06.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a06.exe -lssp +a06.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a06.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/07Ex/Makefile b/2025.02.28/07Ex/Makefile index edeec68..4a8ba04 100644 --- a/2025.02.28/07Ex/Makefile +++ b/2025.02.28/07Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a07.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a07.exe -lssp +a07.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a07.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/08Ex/Makefile b/2025.02.28/08Ex/Makefile index f31a9c0..10f8e7b 100644 --- a/2025.02.28/08Ex/Makefile +++ b/2025.02.28/08Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a08.exe -lssp +a08.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.02.28/09Ex/Makefile b/2025.02.28/09Ex/Makefile index e5f9668..bdaef06 100644 --- a/2025.02.28/09Ex/Makefile +++ b/2025.02.28/09Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a09.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a09.exe -lssp +a09.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a09.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/01Ex/Makefile b/2025.03.07/01Ex/Makefile index 25150b6..72ccb90 100644 --- a/2025.03.07/01Ex/Makefile +++ b/2025.03.07/01Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a01.exe -lssp +a01.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/02Ex/Makefile b/2025.03.07/02Ex/Makefile index f7c9fe2..0195572 100644 --- a/2025.03.07/02Ex/Makefile +++ b/2025.03.07/02Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a02.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a02.exe -lssp +a02.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a02.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/03Ex/Makefile b/2025.03.07/03Ex/Makefile index 13a2d7b..b93deb9 100644 --- a/2025.03.07/03Ex/Makefile +++ b/2025.03.07/03Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a03.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a03.exe -lssp +a03.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a03.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/04Ex/Makefile b/2025.03.07/04Ex/Makefile index f82bcf8..156222b 100644 --- a/2025.03.07/04Ex/Makefile +++ b/2025.03.07/04Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a04.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a04.exe -lssp +a04.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a04.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/05Ex/Makefile b/2025.03.07/05Ex/Makefile index 53339c6..241c28b 100644 --- a/2025.03.07/05Ex/Makefile +++ b/2025.03.07/05Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a05.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a05.exe -lssp +a05.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a05.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/06Ex/Makefile b/2025.03.07/06Ex/Makefile index 0757921..9005111 100644 --- a/2025.03.07/06Ex/Makefile +++ b/2025.03.07/06Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a06.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a06.exe -lssp +a06.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a06.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/07Ex/Makefile b/2025.03.07/07Ex/Makefile index f959ca4..e54542a 100644 --- a/2025.03.07/07Ex/Makefile +++ b/2025.03.07/07Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a07.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a07.exe -lssp +a07.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a07.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/08Ex/Makefile b/2025.03.07/08Ex/Makefile index 5d51a05..7998e79 100644 --- a/2025.03.07/08Ex/Makefile +++ b/2025.03.07/08Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a08.exe -lssp +a08.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/09Ex/Makefile b/2025.03.07/09Ex/Makefile index 8200279..ed669b4 100644 --- a/2025.03.07/09Ex/Makefile +++ b/2025.03.07/09Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a09.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a09.exe -lssp +a09.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a09.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/10Ex/Makefile b/2025.03.07/10Ex/Makefile index d34fe5d..3c88e29 100644 --- a/2025.03.07/10Ex/Makefile +++ b/2025.03.07/10Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a10.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a10.exe -lssp +a10.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a10.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.07/Example/Makefile b/2025.03.07/Example/Makefile index f31a9c0..10f8e7b 100644 --- a/2025.03.07/Example/Makefile +++ b/2025.03.07/Example/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o array.o solve.o sort.o - gcc main.o solve.o array.o sort.o -o a08.exe -lssp +a08.out: main.o array.o solve.o sort.o + gcc main.o solve.o array.o sort.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ sort.o: sort.c gcc $(CFLAGS) -c sort.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/01Ex/Makefile b/2025.03.14/01Ex/Makefile index 25150b6..72ccb90 100644 --- a/2025.03.14/01Ex/Makefile +++ b/2025.03.14/01Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a01.exe -lssp +a01.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/02Ex/Makefile b/2025.03.14/02Ex/Makefile index f7c9fe2..0195572 100644 --- a/2025.03.14/02Ex/Makefile +++ b/2025.03.14/02Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a02.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a02.exe -lssp +a02.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a02.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/03Ex/Makefile b/2025.03.14/03Ex/Makefile index 13a2d7b..b93deb9 100644 --- a/2025.03.14/03Ex/Makefile +++ b/2025.03.14/03Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a03.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a03.exe -lssp +a03.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a03.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/04Ex/Makefile b/2025.03.14/04Ex/Makefile index f82bcf8..156222b 100644 --- a/2025.03.14/04Ex/Makefile +++ b/2025.03.14/04Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a04.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a04.exe -lssp +a04.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a04.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/05Ex/Makefile b/2025.03.14/05Ex/Makefile index 53339c6..241c28b 100644 --- a/2025.03.14/05Ex/Makefile +++ b/2025.03.14/05Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a05.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a05.exe -lssp +a05.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a05.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/06Ex/Makefile b/2025.03.14/06Ex/Makefile index 53339c6..241c28b 100644 --- a/2025.03.14/06Ex/Makefile +++ b/2025.03.14/06Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a05.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a05.exe -lssp +a05.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a05.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/07Ex/Makefile b/2025.03.14/07Ex/Makefile index f959ca4..e54542a 100644 --- a/2025.03.14/07Ex/Makefile +++ b/2025.03.14/07Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a07.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a07.exe -lssp +a07.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a07.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/08Ex/Makefile b/2025.03.14/08Ex/Makefile index 5d51a05..7998e79 100644 --- a/2025.03.14/08Ex/Makefile +++ b/2025.03.14/08Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a08.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a08.exe -lssp +a08.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/09Ex/Makefile b/2025.03.14/09Ex/Makefile index 8200279..ed669b4 100644 --- a/2025.03.14/09Ex/Makefile +++ b/2025.03.14/09Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a09.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a09.exe -lssp +a09.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a09.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/10Ex/Makefile b/2025.03.14/10Ex/Makefile index d34fe5d..3c88e29 100644 --- a/2025.03.14/10Ex/Makefile +++ b/2025.03.14/10Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a10.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a10.exe -lssp +a10.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a10.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/11Ex/Makefile b/2025.03.14/11Ex/Makefile index 813b579..9d4354d 100644 --- a/2025.03.14/11Ex/Makefile +++ b/2025.03.14/11Ex/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a11.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a11.exe -lssp +a11.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a11.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.14/Example/Makefile b/2025.03.14/Example/Makefile index 25150b6..72ccb90 100644 --- a/2025.03.14/Example/Makefile +++ b/2025.03.14/Example/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a01.exe -lssp +a01.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/01Ex/Makefile b/2025.03.21/01Ex/Makefile index f76e57e..f61fd03 100644 --- a/2025.03.21/01Ex/Makefile +++ b/2025.03.21/01Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a01.exe +TARGET = a01.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c gcc $(CFLAGS) -c main.c @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/02Ex/Makefile b/2025.03.21/02Ex/Makefile index 2b446ca..ff84d1c 100644 --- a/2025.03.21/02Ex/Makefile +++ b/2025.03.21/02Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a02.exe +TARGET = a02.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c gcc $(CFLAGS) -c main.c @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/03Ex/Makefile b/2025.03.21/03Ex/Makefile index 600251c..c171c69 100644 --- a/2025.03.21/03Ex/Makefile +++ b/2025.03.21/03Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a03.exe +TARGET = a03.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c gcc $(CFLAGS) -c main.c @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/04Ex/Makefile b/2025.03.21/04Ex/Makefile index b6053af..b05b077 100644 --- a/2025.03.21/04Ex/Makefile +++ b/2025.03.21/04Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a04.exe +TARGET = a04.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c gcc $(CFLAGS) -c main.c @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/05Ex/Makefile b/2025.03.21/05Ex/Makefile index 9d5e1b2..c7e2e40 100644 --- a/2025.03.21/05Ex/Makefile +++ b/2025.03.21/05Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a05.exe +TARGET = a05.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lm -lssp + gcc $(OBJ) -o $(TARGET) -lm main.o: main.c @@ -28,4 +28,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/06Ex/Makefile b/2025.03.21/06Ex/Makefile index cb45184..fd449df 100644 --- a/2025.03.21/06Ex/Makefile +++ b/2025.03.21/06Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a06.exe +TARGET = a06.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c @@ -28,4 +28,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/07Ex/Makefile b/2025.03.21/07Ex/Makefile index 80e226e..0e833be 100644 --- a/2025.03.21/07Ex/Makefile +++ b/2025.03.21/07Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a07.exe +TARGET = a07.out OBJ = main.o array_io.o solve.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c @@ -28,4 +28,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/08Ex/Makefile b/2025.03.21/08Ex/Makefile index 411befe..4d07f7b 100644 --- a/2025.03.21/08Ex/Makefile +++ b/2025.03.21/08Ex/Makefile @@ -8,12 +8,12 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a08.exe +TARGET = a08.out OBJ = main.o array_io.o init_f.o $(TARGET): $(OBJ) solve.o slow.o - gcc $(OBJ) solve.o -o $(TARGET) -lssp - gcc $(OBJ) slow.o -o sa08.exe -lssp + gcc $(OBJ) solve.o -o $(TARGET) + gcc $(OBJ) slow.o -o sa08.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -31,4 +31,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/09Ex/Makefile b/2025.03.21/09Ex/Makefile index d4ff727..b783885 100644 --- a/2025.03.21/09Ex/Makefile +++ b/2025.03.21/09Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a09.exe +TARGET = a09.out OBJ = main.o solve.o array_io.o init_f.o $(TARGET): $(OBJ) - gcc $(OBJ) -o $(TARGET) -lssp + gcc $(OBJ) -o $(TARGET) main.o: main.c gcc $(CFLAGS) -c main.c @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/10Ex/Makefile b/2025.03.21/10Ex/Makefile index ae4969e..0de9fa6 100644 --- a/2025.03.21/10Ex/Makefile +++ b/2025.03.21/10Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -O3 -TARGET = a10.exe +TARGET = a10.out OBJ = main.o solve.o array_io.o init_f.o $(TARGET): $(OBJ) - gcc $^ -o $@ -lm -lssp + gcc $^ -o $@ -lm main.o: main.c gcc $(CFLAGS) -c $^ @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c $^ clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.21/Example/Makefile b/2025.03.21/Example/Makefile index 25150b6..72ccb90 100644 --- a/2025.03.21/Example/Makefile +++ b/2025.03.21/Example/Makefile @@ -1,7 +1,7 @@ FLAGS = -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -O3 -a01.exe: main.o array_io.o solve.o init_f.o - gcc main.o solve.o array_io.o init_f.o -o a01.exe -lssp +a01.out: main.o array_io.o solve.o init_f.o + gcc main.o solve.o array_io.o init_f.o -o a01.out main.o: main.c gcc $(CFLAGS) -c main.c @@ -16,4 +16,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c init_f.c clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.28/01Ex/Makefile b/2025.03.28/01Ex/Makefile index 0cf665e..0cc03d0 100644 --- a/2025.03.28/01Ex/Makefile +++ b/2025.03.28/01Ex/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -fopenmp -O3 -TARGET = a01.exe +TARGET = a01.out OBJ = main.o solve.o array_io.o init_f.o $(TARGET): $(OBJ) - gcc $^ -o $@ -lm -fopenmp -lssp + gcc $^ -o $@ -lm -fopenmp main.o: main.c gcc $(CFLAGS) -c $^ @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c $^ clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.28/02Ex/Makefile b/2025.03.28/02Ex/Makefile new file mode 100644 index 0000000..83e51a9 --- /dev/null +++ b/2025.03.28/02Ex/Makefile @@ -0,0 +1,33 @@ +CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ +-Wempty-body -Wlogical-op -Wold-style-declaration -Wmissing-parameter-type \ +-Wignored-qualifiers -Winit-self -Wshadow -Wtype-limits \ +-Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 \ +-Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs \ +-Wmissing-prototypes -Wmissing-declarations -Wold-style-definition \ +-Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal \ +-Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ +-Wmissing-field-initializers -Wpointer-sign -fopenmp -O3 + +TARGET = a02.out +OBJ = main.o solve.o array_io.o init_f.o matrix.o + +$(TARGET): $(OBJ) + gcc $^ -o $@ -lm -fopenmp + +main.o: main.c + gcc $(CFLAGS) -c $^ + +solve.o: solve.c + gcc $(CFLAGS) -c $^ + +array_io.o: array_io.c + gcc $(CFLAGS) -c $^ + +init_f.o: init_f.c + gcc $(CFLAGS) -c $^ + +matrix.o: matrix.c + gcc $(CFLAGS) -c $^ + +clean: + rm *.o *.out diff --git a/2025.03.28/02Ex/array_io.c b/2025.03.28/02Ex/array_io.c new file mode 100644 index 0000000..f91fbac --- /dev/null +++ b/2025.03.28/02Ex/array_io.c @@ -0,0 +1,40 @@ +#include +#include "array_io.h" + +io_status read_matrix(double *a, int m, int n, const char *name) +{ + int i, j; + FILE *fp; + if (!(fp = fopen(name, "r"))) return ERROR_OPEN; + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) + if (fscanf(fp, "%lf", a + i * n + j) != 1) + {fclose(fp); return ERROR_READ;} + fclose(fp); + return SUCCESS; +} + +void print_matrix(const double *a, int m, int n, int p) +{ + int mp = (m > p ? p : m); + int np = (n > p ? p : n); + int i, j; + + for (i = 0; i < mp; i++) + { + for (j = 0; j < np; j++) + printf(" %10.3e", a[i * n + j]); + printf("\n"); + } +} + +void init_matrix(double *a, int m, int n, int k) +{ + double (*q)(int, int, int, int); + double (*f[])(int, int, int, int) = {f1, f2, f3, f4}; + int i, j; + q = f[k-1]; + for (i = 0; i < m; i++) + for (j = 0; j < n; j++) + a[i * n + j] = q(m, n, i+1, j+1); +} diff --git a/2025.03.28/02Ex/array_io.h b/2025.03.28/02Ex/array_io.h new file mode 100644 index 0000000..c74c9a0 --- /dev/null +++ b/2025.03.28/02Ex/array_io.h @@ -0,0 +1,11 @@ +#ifndef ARRAY_IO_H +#define ARRAY_IO_H + +#include "io_status.h" +#include "init_f.h" + +io_status read_matrix(double *a, int m, int n, const char *name); +void print_matrix(const double *a, int m, int n, int p); +void init_matrix(double *a, int m, int n, int k); + +#endif diff --git a/2025.03.28/02Ex/init_f.c b/2025.03.28/02Ex/init_f.c new file mode 100644 index 0000000..def39b7 --- /dev/null +++ b/2025.03.28/02Ex/init_f.c @@ -0,0 +1,30 @@ +#include "init_f.h" +#include + +#define MAX(n, m) (n < m ? m : n) + +double f1(int m, int n, int i, int j) +{ + return MAX(n, m) - MAX(i, j) + 1; +} + +double f2(int m, int n, int i, int j) +{ + (void)n; + (void)m; + return MAX(i, j); +} + +double f3(int m, int n, int i, int j) +{ + (void)n; + (void)m; + return abs(i - j); +} + +double f4(int m, int n, int i, int j) +{ + (void)n; + (void)m; + return 1./(i+j-1); +} diff --git a/2025.03.28/02Ex/init_f.h b/2025.03.28/02Ex/init_f.h new file mode 100644 index 0000000..40e985b --- /dev/null +++ b/2025.03.28/02Ex/init_f.h @@ -0,0 +1,9 @@ +#ifndef INIT_F_H +#define INIT_F_H + +double f1(int m, int n, int i, int j); +double f2(int m, int n, int i, int j); +double f3(int m, int n, int i, int j); +double f4(int m, int n, int i, int j); + +#endif diff --git a/2025.03.28/02Ex/io_status.h b/2025.03.28/02Ex/io_status.h new file mode 100644 index 0000000..420a981 --- /dev/null +++ b/2025.03.28/02Ex/io_status.h @@ -0,0 +1,13 @@ +#ifndef IO_STATUS_H +#define IO_STATUS_H + +#define LEN 1234 + +typedef enum _io_status +{ + SUCCESS, + ERROR_OPEN, + ERROR_READ +} io_status; + +#endif diff --git a/2025.03.28/02Ex/main.c b/2025.03.28/02Ex/main.c new file mode 100644 index 0000000..467bca5 --- /dev/null +++ b/2025.03.28/02Ex/main.c @@ -0,0 +1,144 @@ +#include +#include +#include +#include "array_io.h" +#include "io_status.h" +#include "matrix.h" +#include "solve.h" + +/* ./a.out t m n p k_a [filename_a] k_x [filename_x] */ +int main(int argc, char *argv[]) +{ + double tau, t, r1, r2, *a, *x_0, *b, *x; + int n, m, p, k_a, k_x, task = 2; + char *name_a = 0, *name_x = 0; + if (!((argc == 7 || argc == 8 || argc == 9) && + sscanf(argv[1], "%lf", &tau) == 1 && + sscanf(argv[2], "%d", &m) == 1 && + sscanf(argv[3], "%d", &n) == 1 && + sscanf(argv[4], "%d", &p) == 1 && + sscanf(argv[5], "%d", &k_a) == 1 && + (k_a >= 0 && k_a <= 4) && + (!(k_a == 0 && argc == 7)) && + ((k_a == 0 && sscanf(argv[7], "%d", &k_x) == 1) || + (k_a != 0 && sscanf(argv[6], "%d", &k_x) == 1)) && + (k_x >= 0 && k_x <= 4) && + (!(k_x == 0 && argc == 7)) && + (!((k_a == 0 && k_x == 0) && argc != 9)))) + { + printf("Usage: %s t m n p k_a [filename_a] k_x [filename_x]\n", argv[0]); + return 1; + } + if (argc != 7) + { + int i_x = 7; + if (k_a == 0) { name_a = argv[6]; i_x++; } + if (k_x == 0) name_x = argv[i_x]; + } + + a = (double *)malloc((size_t)n * (size_t)n * sizeof(double)); + if (!a) + { + printf("Not enough memory\n"); + return 2; + } + x_0 = (double *)malloc((size_t)n * sizeof(double)); + if (!x_0) + { + free(a); + printf("Not enough memory\n"); + return 2; + } + b = (double *)malloc((size_t)n * sizeof(double)); + if (!b) + { + free(a); + free(x_0); + printf("Not enough memory\n"); + return 2; + } + x = (double *)malloc((size_t)n * sizeof(double)); + if (!x) + { + free(a); + free(x_0); + free(b); + printf("Not enough memory\n"); + return 2; + } + + if (name_a) + { /* из файла */ + io_status ret; + ret = read_matrix(a, n, n, name_a); + do { + switch (ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Cannot open %s\n", name_a); + break; + case ERROR_READ: + printf("Cannot read %s\n", name_a); + break; + } + free(a); + free(x_0); + free(b); + free(x); + return 3; + } while (0); + } else init_matrix(a, n, n, k_a); + + if (name_x) + { + io_status ret; + ret = read_matrix(x_0, n, 1, name_x); + do { + switch (ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Cannot open %s\n", name_x); + break; + case ERROR_READ: + printf("Cannot read %s\n", name_x); + break; + } + free(a); + free(x_0); + free(b); + free(x); + return 3; + } while (0); + } else init_matrix(x_0, n, 1, k_x); + + init_vec_b(a, b, n); + + printf("Matrix A:\n"); + print_matrix(a, n, n, p); + printf("Vector x_0:\n"); + print_matrix(x_0, 1, n, p); + printf("Vector b:\n"); + print_matrix(b, 1, n, p); + + t = clock(); + t2_solve(a, x_0, b, x, n, m, tau); + t = (clock() - t) / CLOCKS_PER_SEC; + + r1 = t2_get_r1(a, x, b, n); + r2 = t2_get_r2_value(x, n); + + printf("Vector x_m:\n"); + print_matrix(x, 1, n, p); + printf("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t); + + free(a); + free(x_0); + free(b); + free(x); + + return 0; +} diff --git a/2025.03.28/02Ex/matrix.c b/2025.03.28/02Ex/matrix.c new file mode 100644 index 0000000..f189846 --- /dev/null +++ b/2025.03.28/02Ex/matrix.c @@ -0,0 +1,34 @@ +#include "matrix.h" +#include + +void init_vec_b(const double * restrict a, double * restrict b, int n) +{ + #pragma omp parallel for + for (int i = 0; i < n; ++i) + { + double sum = 0; + +// #pragma omp simd reduction(+:sum) +// for (int k = 1; k < n; k+=2) +// sum += a[i * n + k]; + + for (int k = 0; k < (n-1)/2; ++k) + sum += a[i*n + 2*k+1]; + + b[i] = sum; + } +} + + +void matvec_mul(int n, const double * restrict A, const double * restrict x, double * restrict x_k) +{ + #pragma omp parallel for + for (int i = 0; i < n; i++) + { + double sum = 0; + #pragma omp simd reduction(+:sum) + for (int j = 0; j < n; j++) + sum += A[i * n + j] * x[j]; + x_k[i] = sum; + } +} diff --git a/2025.03.28/02Ex/matrix.h b/2025.03.28/02Ex/matrix.h new file mode 100644 index 0000000..66351d7 --- /dev/null +++ b/2025.03.28/02Ex/matrix.h @@ -0,0 +1,7 @@ +#ifndef MATRIX_H +#define MATRIX_H + +void init_vec_b(const double * restrict a, double * restrict b, int n); +void matvec_mul(int n, const double * restrict A, const double * restrict x, double * restrict x_k); + +#endif diff --git a/2025.03.28/02Ex/solve.c b/2025.03.28/02Ex/solve.c new file mode 100644 index 0000000..26a4c97 --- /dev/null +++ b/2025.03.28/02Ex/solve.c @@ -0,0 +1,79 @@ +#include "solve.h" +#include "matrix.h" +#include + + +void t2_solve(const double * restrict A, double * restrict x_0, const double * restrict b, double * restrict x, int n, int m, double t) +{ + #pragma omp parallel for + for (int k = 0; k < m; ++k) + { + double * swap_temp; + matvec_mul(n, A, x_0, x); + + #pragma omp simd + for (int i = 0; i < n; ++i) + x[i] = (b[i] - x[i]) * t + x_0[i]; + + swap_temp = x; + x = x_0; + x_0 = swap_temp; + } + + if (m % 2 == 0) + for (int i = 0; i < n; i++) + { + double temp = x[i]; + x[i] = x_0[i]; + x_0[i] = temp; + } + else + { + double * swap_temp = x; + x = x_0; + x_0 = swap_temp; + } +} + +double t2_get_r1(const double * restrict A, const double * restrict x_k, const double * restrict b, int n) +{ + double norm_r1x_1 = 0; + double residual_norm_1 = 0; + double r1 = 0; + + #pragma omp parallel for reduction(+:residual_norm_1, norm_r1x_1) + for (int i = 0; i < n; ++i) + { + double bi = b[i]; + double sum = 0; + + #pragma omp simd reduction(+:sum) + for (int j = 0; j < n; ++j) + sum += A[i*n + j] * x_k[j]; + + residual_norm_1 += fabs(sum - bi); + norm_r1x_1 += fabs(bi); + } + + r1 = residual_norm_1 / norm_r1x_1; + + return r1; +} + +double t2_get_r2_value(const double * restrict x_k, int n) +{ + double r2 = 0; + double abs_xi = 0; + double abs_i = 0; + + #pragma omp parallel for reduction(+:abs_xi, abs_i) + for (int i = 0; i < n; ++i) + { + short int modi = i ^ 1; + abs_xi += fabs(x_k[i] - modi); + abs_i += modi; + } + + r2 = abs_xi / abs_i; + return r2; +} diff --git a/2025.03.28/02Ex/solve.h b/2025.03.28/02Ex/solve.h new file mode 100644 index 0000000..6149783 --- /dev/null +++ b/2025.03.28/02Ex/solve.h @@ -0,0 +1,8 @@ +#ifndef SOLVE_H +#define SOLVE_H + +void t2_solve(const double * restrict A, double * restrict x_0, const double * restrict b, double * restrict x, int n, int m, double t); +double t2_get_r1(const double * restrict A, const double * restrict x_k, const double * restrict b, int n); +double t2_get_r2_value(const double * restrict x_k, int n); + +#endif diff --git a/2025.03.28/Example/Makefile b/2025.03.28/Example/Makefile index 0cf665e..0cc03d0 100644 --- a/2025.03.28/Example/Makefile +++ b/2025.03.28/Example/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -fopenmp -O3 -TARGET = a01.exe +TARGET = a01.out OBJ = main.o solve.o array_io.o init_f.o $(TARGET): $(OBJ) - gcc $^ -o $@ -lm -fopenmp -lssp + gcc $^ -o $@ -lm -fopenmp main.o: main.c gcc $(CFLAGS) -c $^ @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c $^ clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.28/Matvecmul/Makefile b/2025.03.28/Matvecmul/Makefile index 0cf665e..0cc03d0 100644 --- a/2025.03.28/Matvecmul/Makefile +++ b/2025.03.28/Matvecmul/Makefile @@ -8,11 +8,11 @@ CFLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused \ -Wwrite-strings -Wno-long-long -std=gnu99 -Wstrict-prototypes \ -Wmissing-field-initializers -Wpointer-sign -fopenmp -O3 -TARGET = a01.exe +TARGET = a01.out OBJ = main.o solve.o array_io.o init_f.o $(TARGET): $(OBJ) - gcc $^ -o $@ -lm -fopenmp -lssp + gcc $^ -o $@ -lm -fopenmp main.o: main.c gcc $(CFLAGS) -c $^ @@ -27,4 +27,4 @@ init_f.o: init_f.c gcc $(CFLAGS) -c $^ clean: - del *.o *.exe + rm *.o *.out diff --git a/2025.03.28/Matvei/Makefile b/2025.03.28/Matvei/Makefile new file mode 100644 index 0000000..a6677ef --- /dev/null +++ b/2025.03.28/Matvei/Makefile @@ -0,0 +1,20 @@ +FLAGS = -mfpmath=sse -fstack-protector-all -W -Wall -Wextra -Wunused -Wcast-align -Werror -pedantic -pedantic-errors -Wfloat-equal -Wpointer-arith -Wformat-security -Wmissing-format-attribute -Wformat=1 -Wwrite-strings -Wcast-align -Wno-long-long -std=gnu99 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wdeclaration-after-statement -Wbad-function-cast -Wnested-externs -Wmaybe-uninitialized -O3 +all: a01.out a02.out a03.out +a01.out: a01.o array.o matrix.o + gcc a01.o array.o matrix.o -lm -o a01.out +a02.out: a02.o array.o matrix.o + gcc a02.o array.o matrix.o -lm -o a02.out +a03.out: a03.o array.o matrix.o + gcc a03.o array.o matrix.o -lm -o a03.out +array.o: + gcc -c $(FLAGS) -o array.o array.c +matrix.o: + gcc -c $(FLAGS) -o matrix.o matrix.c +a01.o: + gcc -c $(FLAGS) -o a01.o task01.c +a02.o: + gcc -c $(FLAGS) -o a02.o task02.c +a03.o: + gcc -c $(FLAGS) -o a03.o task03.c +clean: + rm -f *.o *.out diff --git a/2025.03.28/Matvei/array.c b/2025.03.28/Matvei/array.c new file mode 100644 index 0000000..e468ec3 --- /dev/null +++ b/2025.03.28/Matvei/array.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include "io_status.h" +#include "array.h" +#include "matrix.h" + +io_status read_matrix(double* a, int n, int m, const char* name) + { + int i, j; + FILE* fp; + if (!(fp = fopen(name, "r"))) + return ERROR_OPEN; + for (i = 0; i < n; i++) + { + for (j = 0; j < m; j++) + { + if (fscanf(fp, "%lf", a + i * m + j) != 1) + { + fclose(fp); + return ERROR_READ; + } + } + } + fclose(fp); + return SUCCESS; + } + +void print_matrix(const double* a, int n, int m, int p) + { + int np = (n > p ? p : n); + int mp = (m > p ? p : m); + int i, j; + for (i = 0; i < np; i++) + { + for (j = 0; j < mp; j++) + printf(" %10.3e", a[i * m + j]); + printf("\n"); + } + } + +void init_matrix(double* a, int n, int m, int k) + { + int i, j; + for (i = 0; i < n; i++) + { + for (j = 0; j < m; j++) + a[i * m + j] = f(k, n, m, i+1, j+1); + } + } + +double f(int k, int n, int m, int i, int j) + { + switch (k) + { + case 1: return (n >= m ? n : m) - (i >= j ? i : j) + 1; + case 2: return (i >= j ? i : j); + case 3: return (i - j >= 0 ? i - j : j - i); + case 4: return 1./(i + j - 1); + } + return -1e308; + } + +void init_vector(double* b, double* a, int n) + { + int i, k; + double sum; + for (i = 0; i < n; i++) + { + sum = 0; + for (k = 1; k < n; k += 2) sum += a[i * n + k]; + b[i] = sum; + } + } diff --git a/2025.03.28/Matvei/array.h b/2025.03.28/Matvei/array.h new file mode 100644 index 0000000..e626337 --- /dev/null +++ b/2025.03.28/Matvei/array.h @@ -0,0 +1,5 @@ +io_status read_matrix(double*, int, int, const char*); +void print_matrix(const double*, int, int, int); +void init_matrix(double*, int, int, int); +double f(int, int, int, int, int); +void init_vector(double*, double*, int); diff --git a/2025.03.28/Matvei/io_status.h b/2025.03.28/Matvei/io_status.h new file mode 100644 index 0000000..4234d9c --- /dev/null +++ b/2025.03.28/Matvei/io_status.h @@ -0,0 +1,6 @@ +typedef enum io_status_ + { + SUCCESS, + ERROR_OPEN, + ERROR_READ, + } io_status; diff --git a/2025.03.28/Matvei/matrix.c b/2025.03.28/Matvei/matrix.c new file mode 100644 index 0000000..5e22a00 --- /dev/null +++ b/2025.03.28/Matvei/matrix.c @@ -0,0 +1,99 @@ +#include +#include +#include +#include "matrix.h" + +void multmatvec(double* a, double* x1, double* x2, int n) + { + int i, j; + double sum; + for (i = 0; i < n; i++) + { + sum = 0; + for (j = 0; j < n; j++) + sum += a[i * n+ j] * x1[j]; + x2[i] = sum; + } + } + +double scalp(double* a, double* b, int n) + { + int i; + double mult = 0; + for (i = 0; i < n; i++) mult += a[i] * b[i]; + return mult; + } + +double count_task1(double* a, double* x, double r1, int n) + { + int i, j; + double mltd_el_x, sum, modsum1 = 0, modsum2 = 0; + for (i = 0; i < n; i++) + { + sum = 0; + for (j = 0; j < n; j++) sum += a[i * n + j] * x[j]; + mltd_el_x = r1 * x[i]; + modsum1 += fabs(sum - mltd_el_x); + modsum2 += fabs(mltd_el_x); + } + return modsum1 / modsum2; + } + +double count_r1(double* a, double* b, double* x, int n) + { + int i, j; + double el_b, sum, modsum1 = 0, modsum2 = 0; + for (i = 0; i < n; i++) + { + sum = 0; + for (j = 0; j < n; j++) sum += a[i * n + j] * x[j]; + el_b = b[i]; + modsum1 = fabs(sum - el_b); + modsum2 = fabs(el_b); + } + return modsum1 / modsum2; + } + +double count_r2(double* x, int n) + { + int i; + double modsum = 0; + int ost, sum = 0; + for (i = 0; i < n; i++) + { + ost = (i + 1) % 2; + modsum += fabs(x[i] - ost); + sum += ost; + } + return modsum / sum; + } + +void vecdiff(double* a, double* b, int n) + { + int i; + for (i = 0; i < n; i++) a[i] -= b[i]; + } + +void vecmult(double* a, double lambda, int n) + { + int i; + for (i = 0; i < n; i++) a[i] = lambda * a[i]; + } + +void veccpy(double* a, double* b, int n) + { + int i; + for (i = 0; i < n; i++) a[i] = b[i]; + } + +void veccomb(double lambda, double* a, double myu, double* b, int n) + { + int i; + for (i = 0; i < n; i++) a[i] = lambda * a[i] + myu * b[i]; + } + +int equal(double a, double b) + { + if (fabs(a - b) <= EPS * fmax(fabs(a), fabs(b))) return 1; + return 0; + } diff --git a/2025.03.28/Matvei/matrix.h b/2025.03.28/Matvei/matrix.h new file mode 100644 index 0000000..bc71ea1 --- /dev/null +++ b/2025.03.28/Matvei/matrix.h @@ -0,0 +1,12 @@ +#define EPS (1e-9) + +void multmatvec(double*, double*, double*, int); +double scalp(double*, double*, int); +void vecdiff(double*, double*, int); +void vecmult(double*, double, int); +void veccpy(double*, double*, int); +void veccomb(double, double*, double, double*, int); +double count_task1(double*, double*, double, int); +double count_r1(double*, double*, double*, int); +double count_r2(double*, int); +int equal(double, double); diff --git a/2025.03.28/Matvei/task01.c b/2025.03.28/Matvei/task01.c new file mode 100644 index 0000000..3aa68d8 --- /dev/null +++ b/2025.03.28/Matvei/task01.c @@ -0,0 +1,152 @@ +#include +#include +#include +#include +#include "io_status.h" +#include "array.h" +#include "matrix.h" + +double solve1(double*, double*, double*, int, int); + +int main(int argc, char* argv[]) + { + int task = 1; + double* a; + double* x0; + double* x; + int n, m, p, k1, k2; + char* name1 = 0; + char* name2 = 0; + double r1, r2; + double t; + if (!((argc == 6 || argc == 7 || argc == 8) && sscanf(argv[1], "%d", &m) == 1 && sscanf(argv[2], "%d", &n) == 1 && sscanf(argv[3], "%d", &p) == 1 && sscanf(argv[4], "%d", &k1) == 1 && k1 >= 0 && k1 <= 4)) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + if (k1 == 0) + { + if (!(sscanf(argv[6], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + name1 = argv[5]; + } + else + { + if (!(sscanf(argv[5], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + } + if (k2 == 0) + { + if (k1 == 0) name2 = argv[7]; + else name2 = argv[6]; + } + a = (double*) malloc(n * n * sizeof(double)); + if (!a) + { + printf("Not enough memory\n"); + return 2; + } + if (name1) + { + io_status ret; + ret = read_matrix(a, n, n, name1); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name1); + break; + case ERROR_READ: + printf("Can not read file %s\n", name1); + break; + } + free(a); + return 3; + } while (0); + } + else + init_matrix(a, n, n, k1); + x0 = (double*) malloc(n * sizeof(double)); + if (!x0) + { + printf("Not enough memory\n"); + free(a); + return 2; + } + x = (double*) malloc(n * sizeof(double)); + if (!x) + { + printf("Not enough memory\n"); + free(a); + free(x0); + return 2; + } + if (name2) + { + io_status ret; + ret = read_matrix(x0, n, 1, name2); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name2); + break; + case ERROR_READ: + printf("Can not read file %s\n", name2); + break; + } + free(a); + free(x0); + free(x); + return 3; + } while (0); + } + else + init_matrix(x0, n, 1, k2); + printf("Matrix:\n"); + print_matrix(a, n, n, p); + printf("Vector:\n"); + print_matrix(x0, n, 1, p); + t = clock(); + r1 = solve1(a, x0, x, n, m); + t = (clock() - t) / CLOCKS_PER_SEC; + r2 = count_task1(a, x, r1, n); + + printf("Vector x:\n"); + if (m % 2) + print_matrix(x, 1, n, p); + else + print_matrix(x0, 1, n, p); + printf ("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t); + free(a); + free(x0); + free(x); + return 0; + } + +double solve1(double* a, double* x0, double* x, int n, int m) + { + int k; + double lambda; + if (m <= 0) return 0; + for (k = 0; k <= m; k++) + { + if (k % 2) multmatvec(a, x, x0, n); + else multmatvec(a, x0, x, n); + } + if (m % 2) lambda = scalp(x0, x, n) / scalp(x, x, n); + else lambda = scalp(x, x0, n) / scalp(x0, x0, n); + return lambda; + } diff --git a/2025.03.28/Matvei/task02.c b/2025.03.28/Matvei/task02.c new file mode 100644 index 0000000..00364cd --- /dev/null +++ b/2025.03.28/Matvei/task02.c @@ -0,0 +1,163 @@ +#include +#include +#include +#include +#include "io_status.h" +#include "array.h" +#include "matrix.h" + +void solve2(double*, double*, double*, double*, int, int, double); + +int main(int argc, char* argv[]) + { + int task = 2; + double* a; + double* x0; + double* x; + double* b; + int n, m, p, k1, k2; + char* name1 = 0; + char* name2 = 0; + double tau; + double r1, r2; + double t; + if (!((argc == 7 || argc == 8 || argc == 9) && sscanf(argv[1], "%lf", &tau) == 1 && sscanf(argv[2], "%d", &m) == 1 && sscanf(argv[3], "%d", &n) == 1 && sscanf(argv[4], "%d", &p) == 1 && sscanf(argv[5], "%d", &k1) == 1 && k1 >= 0 && k1 <= 4)) + { + printf("Usage: %s tau n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + if (k1 == 0) + { + if (!(sscanf(argv[7], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s tau n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + name1 = argv[6]; + } + else + { + if (!(sscanf(argv[6], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s tau n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + } + if (k2 == 0) + { + if (k1 == 0) name2 = argv[8]; + else name2 = argv[7]; + } + a = (double*) malloc(n * n * sizeof(double)); + if (!a) + { + printf("Not enough memory\n"); + return 2; + } + if (name1) + { + io_status ret; + ret = read_matrix(a, n, n, name1); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name1); + break; + case ERROR_READ: + printf("Can not read file %s\n", name1); + break; + } + free(a); + return 3; + } while (0); + } + else + init_matrix(a, n, n, k1); + x0 = (double*) malloc(n * sizeof(double)); + if (!x0) + { + printf("Not enough memory\n"); + free(a); + return 2; + } + x = (double*) malloc(n * sizeof(double)); + if (!x) + { + printf("Not enough memory\n"); + free(a); + free(x0); + return 2; + } + b = (double*) malloc(n * sizeof(double)); + if (!b) + { + printf("Not enough memory\n"); + free(a); + free(x0); + free(x); + return 2; + } + if (name2) + { + io_status ret; + ret = read_matrix(x0, n, 1, name2); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name2); + break; + case ERROR_READ: + printf("Can not read file %s\n", name2); + break; + } + free(a); + free(x0); + free(x); + free(b); + return 3; + } while (0); + } + else + init_matrix(x0, n, 1, k2); + init_vector(b, a, n); + printf("Matrix:\n"); + print_matrix(a, n, n, p); + printf("Vector:\n"); + print_matrix(x0, 1, n, p); + printf("Vector b:\n"); + print_matrix(b, 1, n, p); + t = clock(); + solve2(a, x0, x, b, n, m, tau); + t = (clock() - t) / CLOCKS_PER_SEC; + r1 = count_r1(a, b, x, n); + r2 = count_r2(x, n); + printf("New vector:\n"); + print_matrix(x, n, 1, p); + printf ("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t); + free(a); + free(x0); + free(x); + free(b); + return 0; + } + +void solve2(double* a, double* x0, double* x, double* b, int n, int m, double tau) + { + int k; + veccpy(x, x0, n); + for (k = 1; k <= m; k++) + { + multmatvec(a, x, x0, n); + vecdiff(x0, b, n); + vecmult(x0, tau, n); + vecdiff(x, x0, n); + } + } diff --git a/2025.03.28/Matvei/task03.c b/2025.03.28/Matvei/task03.c new file mode 100644 index 0000000..75dd7ef --- /dev/null +++ b/2025.03.28/Matvei/task03.c @@ -0,0 +1,180 @@ +#include +#include +#include +#include +#include "io_status.h" +#include "array.h" +#include "matrix.h" + +void solve3(double*, double*, double*, double*, double*, int, int); + +int main(int argc, char* argv[]) + { + int task = 3; + double* a; + double* x0; + double* x; + double* b; + double* r; + int n, m, p, k1, k2; + char* name1 = 0; + char* name2 = 0; + double r1, r2; + double t; + if (!((argc == 6 || argc == 7 || argc == 8) && sscanf(argv[1], "%d", &m) == 1 && sscanf(argv[2], "%d", &n) == 1 && sscanf(argv[3], "%d", &p) == 1 && sscanf(argv[4], "%d", &k1) == 1 && k1 >= 0 && k1 <= 4)) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + if (k1 == 0) + { + if (!(sscanf(argv[6], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + name1 = argv[5]; + } + else + { + if (!(sscanf(argv[5], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + } + if (k2 == 0) + { + if (k1 == 0) name2 = argv[7]; + else name2 = argv[6]; + } + a = (double*) malloc(n * n * sizeof(double)); + if (!a) + { + printf("Not enough memory\n"); + return 2; + } + if (name1) + { + io_status ret; + ret = read_matrix(a, n, n, name1); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name1); + break; + case ERROR_READ: + printf("Can not read file %s\n", name1); + break; + } + free(a); + return 3; + } while (0); + } + else + init_matrix(a, n, n, k1); + x0 = (double*) malloc(n * sizeof(double)); + if (!x0) + { + printf("Not enough memory\n"); + free(a); + return 2; + } + x = (double*) malloc(n * sizeof(double)); + if (!x) + { + printf("Not enough memory\n"); + free(a); + free(x0); + return 2; + } + b = (double*) malloc(n * sizeof(double)); + if (!b) + { + printf("Not enough memory\n"); + free(a); + free(x0); + free(x); + return 2; + } + r = (double*) malloc(n * sizeof(double)); + if (!r) + { + printf("Not enough memory\n"); + free(a); + free(x0); + free(x); + free(b); + return 2; + } + if (name2) + { + io_status ret; + ret = read_matrix(x0, n, 1, name2); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name2); + break; + case ERROR_READ: + printf("Can not read file %s\n", name2); + break; + } + free(a); + free(x0); + free(x); + free(b); + free(r); + return 3; + } while (0); + } + else + init_matrix(x0, n, 1, k2); + init_vector(b, a, n); + printf("Matrix:\n"); + print_matrix(a, n, n, p); + printf("Vector:\n"); + print_matrix(x0, n, 1, p); + printf("Vector b:\n"); + print_matrix(b, n, 1, p); + t = clock(); + solve3(a, x0, x, b, r, n, m); + t = (clock() - t) / CLOCKS_PER_SEC; + r1 = count_r1(a, b, x, n); + r2 = count_r2(x, n); + printf("New vector:\n"); + print_matrix(x, n, 1, p); + printf("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t); + free(a); + free(x0); + free(x); + free(b); + free(r); + return 0; + } + +void solve3(double* a, double* x0, double* x, double* b, double* r, int n, int m) + { + int k; + double tau, scalp2; + veccpy(x, x0, n); + multmatvec(a, x, r, n); + vecdiff(r, b, n); + for (k = 1; k <= m; k++) + { + multmatvec(a, r, x0, n); + scalp2 = scalp(x0, r, n); + if (!equal(scalp2, 0)) tau = scalp(r, r, n) / scalp2; + else break; + veccomb(1, x, -tau, r, n); + veccomb(1, r, -tau, x0, n); + } + } diff --git a/2025.03.28/Matvei/task04.c b/2025.03.28/Matvei/task04.c new file mode 100644 index 0000000..7344dde --- /dev/null +++ b/2025.03.28/Matvei/task04.c @@ -0,0 +1,180 @@ +#include +#include +#include +#include +#include "io_status.h" +#include "array.h" +#include "matrix.h" + +void solve4(double*, double*, double*, double*, double*, int, int); + +int main(int argc, char* argv[]) + { + int task = 4; + double* a; + double* x0; + double* x; + double* b; + double* r; + int n, m, p, k1, k2; + char* name1 = 0; + char* name2 = 0; + double r1, r2; + double t; + if (!((argc == 6 || argc == 7 || argc == 8) && sscanf(argv[1], "%d", &m) == 1 && sscanf(argv[2], "%d", &n) == 1 && sscanf(argv[3], "%d", &p) == 1 && sscanf(argv[4], "%d", &k1) == 1 && k1 >= 0 && k1 <= 4)) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + if (k1 == 0) + { + if (!(sscanf(argv[6], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + name1 = argv[5]; + } + else + { + if (!(sscanf(argv[5], "%d", &k2) == 1) && k2 >= 0 && k2 <= 4) + { + printf("Usage: %s n m p k1 [file1] k2 [file2]\n", argv[0]); + return 1; + } + } + if (k2 == 0) + { + if (k1 == 0) name2 = argv[7]; + else name2 = argv[6]; + } + a = (double*) malloc(n * n * sizeof(double)); + if (!a) + { + printf("Not enough memory\n"); + return 2; + } + if (name1) + { + io_status ret; + ret = read_matrix(a, n, n, name1); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name1); + break; + case ERROR_READ: + printf("Can not read file %s\n", name1); + break; + } + free(a); + return 3; + } while (0); + } + else + init_matrix(a, n, n, k1); + x0 = (double*) malloc(n * sizeof(double)); + if (!x0) + { + printf("Not enough memory\n"); + free(a); + return 2; + } + x = (double*) malloc(n * sizeof(double)); + if (!x) + { + printf("Not enough memory\n"); + free(a); + free(x0); + return 2; + } + b = (double*) malloc(n * sizeof(double)); + if (!b) + { + printf("Not enough memory\n"); + free(a); + free(x0); + free(x); + return 2; + } + r = (double*) malloc(n * sizeof(double)); + if (!r) + { + printf("Not enough memory\n"); + free(a); + free(x0); + free(x); + free(b); + return 2; + } + if (name2) + { + io_status ret; + ret = read_matrix(x0, n, 1, name2); + do + { + switch(ret) + { + case SUCCESS: + continue; + case ERROR_OPEN: + printf("Can not open file %s\n", name2); + break; + case ERROR_READ: + printf("Can not read file %s\n", name2); + break; + } + free(a); + free(x0); + free(x); + free(b); + free(r); + return 3; + } while (0); + } + else + init_matrix(x0, n, 1, k2); + init_vector(b, a, n); + printf("Matrix:\n"); + print_matrix(a, n, n, p); + printf("Vector:\n"); + print_matrix(x0, n, 1, p); + printf("Vector b:\n"); + print_matrix(b, n, 1, p); + t = clock(); + solve4(a, x0, x, b, r, n, m); + t = (clock() - t) / CLOCKS_PER_SEC; + r1 = count_r1(a, b, x, n); + r2 = count_r2(x, n); + printf("New vector:\n"); + print_matrix(x, n, 1, p); + printf("%s : Task = %d Res1 = %e Res2 = %e Elapsed = %.2f\n", argv[0], task, r1, r2, t); + free(a); + free(x0); + free(x); + free(b); + free(r); + return 0; + } + +void solve4(double* a, double* x0, double* x, double* b, double* r, int n, int m) + { + int k; + double tau, scalp2; + veccpy(x, x0, n); + multmatvec(a, x, r, n); + vecdiff(r, b, n); + for (k = 1; k <= m; k++) + { + multmatvec(a, r, x0, n); + scalp2 = scalp(x0, r, n); + if (!equal(scalp2, 0)) tau = scalp(r, r, n) / scalp2; + else break; + veccomb(1, x, -tau, r, n); + veccomb(1, r, -tau, x0, n); + } + }