Initial commit

This commit is contained in:
2024-03-09 17:32:59 +02:00
parent 72cf3bd8ff
commit 8175cbbdbf
18 changed files with 591 additions and 0 deletions

109
Lab_5/code.c Normal file
View File

@@ -0,0 +1,109 @@
#include <stdio.h>
#include <stdlib.h>
void line_pr(short int len)
{
for (short int i = 0; i < len; i++) {
printf("-");
}
}
int main ()
{
short int rows, columns, indent, c_indent, line_len;
int temp;
printf("Input the number of rows and columns separated with a space: ");
scanf("%hd %hd", &rows, &columns);
int array[rows][columns];
for (short int i = 0; i < rows; i++) {
for (short int j = 0; j < columns; j++) {
printf("Input a value for %hd %hd: ", i + 1, j + 1);
scanf("%d", &array[i][j]);
}
}
printf("Matrix before sorting:\n");
indent = 6;
if (rows >= columns) {
c_indent = floor(log10(rows));
} else {
c_indent = floor(log10(columns));
}
c_indent +=2;
line_len = c_indent + indent * columns + columns * 2 + 1;
printf("%*c|", c_indent, *" ");
for (short int i = 1; i <= columns; i++) {
printf("%*d |", indent, i);
}
printf("\n");
line_pr(line_len);
printf("\n");
for (short int i = 0; i < rows; i++) {
printf("%*d|", c_indent, i+1);
for (short int j = 0; j < columns; j++) {
printf("%*d |", indent, array[i][j]);
}
printf("\n");
line_pr(line_len);
printf("\n");
}
for (short int i = 2; i < columns; i+=2) {
temp = array[0][i];
short int j = 0;
while (array[0][j] < temp) {
j+=2;
}
for (short int k = i - 2; k >= j; k-=2) {
array[0][k+2] = array[0][k];
}
array[0][j] = temp;
}
printf("Matrix after sorting:\n");
printf("%*c|", c_indent, *" ");
for (short int i = 1; i <= columns; i++) {
printf("%*d |", indent, i);
}
printf("\n");
line_pr(line_len);
printf("\n");
for (short int i = 0; i < rows; i++) {
printf("%*d|", c_indent, i+1);
for (short int j = 0; j < columns; j++) {
printf("%*d |", indent, array[i][j]);
}
printf("\n");
line_pr(line_len);
printf("\n");
}
return 0;
}

5
Lab_5/run.sh Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
gcc code.c -o code -lm
./code

48
Lab_5/test.py Normal file
View File

@@ -0,0 +1,48 @@
#!/bin/python3
import random
import time
import os
#r, c = map(int, input("R c: ").split())
#arr_size = 100
arr = [random.randint(0, 100) for i in range(50)]
#a = [[ round((random.random() - 0.5) * 20, 3) for i in range(ar_size[0]) ] for j in range(ar_size[1])]
#a = [ [ round((random.random() - 0.5) * 20, 3) for i in range(round(ar_size[0] / 2)) ] * 2 for j in range(ar_size[1]) ]
#a[0][4] = 5
#a[0][7] = 5
print(len(arr))
for i in range(5, -1, -1):
print(f"Starting in {i}...")
time.sleep(1)
map(str, arr)
for i in arr:
for j in range(2):
os.system(f"xdotool type --delay 2 -- {i}")
os.system("xdotool key Return")
'''
for i in range(0, 10):
for j in range(3):
os.system(f"xdotool type --delay 2 -- {arr[i]}")
os.system("xdotool key Return")
# print(arr[i], end = " ")
for j in range(3):
os.system(f"xdotool type --delay 2 -- {arr[i+1]}")
os.system("xdotool key Return")
# print(arr[i+1], end = " ")
for j in range(3):
os.system(f"xdotool type --delay 2 -- {arr[i+2]}")
os.system("xdotool key Return")
# print("\n")'''