mirror of
https://github.com/krahets/hello-algo.git
synced 2026-05-04 02:33:11 +08:00
build
This commit is contained in:
@@ -162,7 +162,7 @@ status: new
|
||||
int forLoop(int n) {
|
||||
int res = 0;
|
||||
// 循环求和 1, 2, ..., n-1, n
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
res += i;
|
||||
}
|
||||
return res;
|
||||
@@ -437,9 +437,9 @@ status: new
|
||||
// 循环求和 1, 2, 4, 5...
|
||||
while (i <= n) {
|
||||
res += i;
|
||||
i += 1; // 更新条件变量
|
||||
res += i;
|
||||
i *= 2; // 更新条件变量
|
||||
// 更新条件变量
|
||||
i += 1;
|
||||
i *= 2;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -759,11 +759,10 @@ status: new
|
||||
// n * n 为对应点数量,"(i, j), " 对应字符串长最大为 6+10*2,加上最后一个空字符 \0 的额外空间
|
||||
int size = n * n * 26 + 1;
|
||||
char *res = malloc(size * sizeof(char));
|
||||
|
||||
// 循环 i = 1, 2, ..., n-1, n
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
for (int i = 1; i <= n; i++) {
|
||||
// 循环 j = 1, 2, ..., n-1, n
|
||||
for (int j = 1; j <= n; ++j) {
|
||||
for (int j = 1; j <= n; j++) {
|
||||
char tmp[26];
|
||||
snprintf(tmp, sizeof(tmp), "(%d, %d), ", i, j);
|
||||
strncat(res, tmp, size - strlen(res) - 1);
|
||||
|
||||
Reference in New Issue
Block a user