vorking #2 both guys

This commit is contained in:
2025-10-23 19:25:48 +07:00
parent 5e673084bc
commit e5e1c10b24
11 changed files with 423 additions and 0 deletions

18
lab_2/kirill/lib_d.c Normal file
View File

@@ -0,0 +1,18 @@
#include <string.h>
int replace_char_line(char *buf, int key, int *replacements_left) {
(void)key;
int replaced = 0;
int count = 0;
for (size_t i = 0; buf[i] != '\0'; i++) {
if (buf[i] == '\n') continue;
count++;
if (count % 3 == 0 && *replacements_left > 0) {
buf[i] = ' ';
replaced++;
(*replacements_left)--;
}
}
return replaced;
}