小编Wei*_*ida的帖子

是否有O(n)算法为正整数数组生成无前缀数组?

对于数组[4,3,5,1,2],我们调用4的前缀为NULL,4的前缀为0; 前缀3为[4],前缀为3为0,因为前缀中没有小于3; 前缀5是[4,3],前缀少于5是2,因为4和3都小于5; 前缀1为[4,3,5],前缀为1为0,因为前缀中没有小于1; 前缀2是[4,3,5,1],前缀少于2是1,因为只有1小于2

因此对于数组[4,3,5,1,2],我们得到[0,0,2,0,1]的无前缀的arrary,我们可以得到一个O(n)算法来获得无前缀的数组吗?

arrays algorithm integer prefix

5
推荐指数
1
解决办法
225
查看次数

make无法在Cygwin中运行

我在Cygwin中遇到了c代码编译的问题.我的环境是Window Xp中的Cygwin,

$ which make
/cygdrive/c/MinGW/bin/make

$ which cc
/usr/bin/cc.exe
Run Code Online (Sandbox Code Playgroud)

我的makefile看起来像:

CC=cc
CFLAGS= -g  -std=c99 -Wall -pedantic
EXE=graph
SRCS=graph.c
$(EXE):$(OBJS)
        $(CC) $(CFLAGS) $(SRCS) -o $(EXE)
CLEAN:
        rm -fr $(OBJS) $(EXE)*
Run Code Online (Sandbox Code Playgroud)

该文件graph.c与...在同一文件夹中cc.

我跑make,但它显示

cc -g  -std=c99 -Wall -pedantic graph.c -o graph
process_begin: CreateProcess(C:\cygwin\bin\cc.exe, cc -g -std=c99 -Wall -pedantic graph.c -o graph, ...) failed.
make (e=5): Access is denied.
make: *** [graph] Error 5
Run Code Online (Sandbox Code Playgroud)

但是当我运行cc -g -std=c99 -Wall -pedantic graph.c -o graph 它时工作正常.

我是Cygwin的新手,我的设置或makefile有什么问题?

cygwin makefile

0
推荐指数
1
解决办法
8342
查看次数

如何让它不共享相同的内存

#include <stdio.h>
typedef struct TESTCASE{
    char *before; 
}ts;
int main(void) {
     ts t[2] = {{"abcd"}, 
                {"abcd"}};
     t[0].before[0] = t[0].before[2] = t[0].before[3] = 'b';
     printf("%s - %s\n", t[0].before, t[1].before);
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是

bbbb - bbbb

我在Cygwin中用gcc编译

cc -g test.c -o test

我的问题是,使用什么编译选项,我可以收获bbbb - abcd的结果?

c

0
推荐指数
1
解决办法
53
查看次数

标签 统计

algorithm ×1

arrays ×1

c ×1

cygwin ×1

integer ×1

makefile ×1

prefix ×1