32 lines
627 B
C
32 lines
627 B
C
#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;
|
|
}
|