为了运行https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/1/array/21/上面的程序。
为此下载了编译器。
如下:
官方网站下载:http://www.codeblocks.org/downloads/26
下载无安装版本:
打开后的界面如下
出现的问题:
ERROR: You need to specify a debugger program in the debuggers's settings.
(For MinGW compilers, it's 'gdb.exe' (without the quotes))
(For MSVC compilers, it's 'cdb.exe' (without the quotes))
网上查找配置:
1:https://stackoverflow.com/questions/21083560/how-do-you-specify-a-debugger-program-in-codeblocks-12-11/33289596
整理好了,但是会出现只能运行一次:
解决参考:http://tieba.baidu.com/p/3491019377
配置界面:
A:
B:
注意选择的是:gdb.32
例如:
2、官方参考的安装教程:
http://wiki.codeblocks.org/index.php?title=MinGW_installation#TDM-GCC
上面所运行的代码:
#include <stdio.h>
#include <stdlib.h>
int array[10]={0,0,1,1,1,2,2,3,3,4};
int size=10;
int j=0;
int main()
{
for (int i=0;i<size-1; i++)
{
while (array[i] == array[i+1])
{
i++;
}
array[j++] = array[i];
i--;
}
return j;
printf("Hello world!\n");
return 0;
}
运行调试完成的界面:
如何调试参考:http://www.docin.com/p-894823578.html
完成!
应该使用下面的C代码:
#include <stdio.h>
#include <stdlib.h>
int array[10]={0,0,1,1,1,2,2,3,3,4};
int size=10;
int j=0;
int main()
{
for(int i=0;i<size;i++)
{
while(array[i]==array[i+1])
{
i++;
}
array[j++]=array[i];
//i--;
}
return j;
// printf("hello world 7\n");
// return 0;
}