test done

This commit is contained in:
2023-10-06 20:42:19 +02:00
parent 84298c0b81
commit 5120cc20c2
2 changed files with 91 additions and 0 deletions

31
axis/task3.c Normal file
View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
char* solution(int N) {
static const int size = (int)('z' - 'a');
const int interval = (int)ceil((double)N / (double)size);
char* str = (char*)malloc((N + 1) * sizeof(char));
str[N] = '\0';
int count = 0;
char offset = 0;
for (int i = 0; i < N; ++i) {
str[i] = 'a' + offset;
if (++count >= interval) {
count = 0;
++offset;
}
}
return str;
}
int main() {
{
char* str = solution(3);
printf("%s\n", str);
free(str);
}
return 0;
}