Data Structures Algorithms 简明教程
Data Structures & Algorithms - Environment Setup
Online Editor & Compiler
我们已经设置了一个在线环境,让您可以在四种不同的编程语言中编译和运行数据结构和算法程序:C、C++、Java 和 Python。
We have setup an online environment for you to compile and run your data Structure and Algorithms programs in four different programming languages: C, C++, Java, Python.
Local Environment Setup
如果您仍愿意为 C 编程语言设置自己的环境,那么您需要在计算机上安装以下两个工具:(a) 文本编辑器和 (b) C 编译器。
If you are still willing to set up your own environment for C programming language, you need the following two tools available on your computer, (a) Text Editor and (b) The C Compiler.
Text Editor
这将用于键入您的程序。一些编辑器的示例包括 Windows 记事本、OS 编辑命令、Brief、Epsilon、EMACS 以及 vim 或 vi。
This will be used to type your program. Examples of few editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.
文本编辑器的名称和版本可能因不同的操作系统而异。例如,记事本将用于 Windows,而且 vim 或 vi 也可用于 Windows 以及 Linux 或 UNIX。
The name and the version of the text editor can vary on different operating systems. For example, Notepad will be used on Windows, and vim or vi can be used on Windows as well as Linux or UNIX.
您使用编辑器创建的文件称为源文件,其中包含程序源代码。C 程序的源文件通常以扩展名 " .c " 命名。
The files you create with your editor are called source files and contain program source code. The source files for C programs are typically named with the extension ".c".
在开始编程之前,请确保到位文本编辑器,并且你具备编写计算机程序、将其保存在文件中、对其进行编译,最后执行它的经验。
Before starting your programming, make sure you have one text editor in place and you have enough experience to write a computer program, save it in a file, compile it, and finally execute it.
The C Compiler
写在源文件中的源代码是程序的人类可读源代码。它需要“编译”才能变为机器语言,以便 CPU 实际上按照给定的说明执行程序。
The source code written in the source file is the human readable source for your program. It needs to be "compiled", to turn into machine language so that your CPU can actually execute the program as per the given instructions.
此 C 编程语言编译器将用于将你的源代码编译为最终的可执行程序。我们假设你对编程语言编译器具备基础知识。
This C programming language compiler will be used to compile your source code into a final executable program. We assume you have the basic knowledge about a programming language compiler.
使用最频繁且免费的编译器是 GNU C/C++ 编译器。否则,如果具有相应的操作系统 (OS),你可以有 Hewlett-Packard (HP) 或 Solaris 的编译器。
Most frequently used and free available compiler is GNU C/C++ compiler. Otherwise, you can have compilers either from HP or Solaris if you have respective Operating Systems (OS).
以下部分指导如何在各种操作系统上安装 GNU C/C 编译器。我们一同提到 C/C,因为 GNU GCC 编译器同时适用于 C 和 C++ 编程语言。
The following section guides you on how to install GNU C/C compiler on various OS. We are mentioning C/C together because GNU GCC compiler works for both C and C++ programming languages.
Installation on UNIX/Linux
如果您使用 Linux or UNIX ,那么通过从命令行输入以下命令来检查您的系统上是否安装了 GCC -
If you are using Linux or UNIX, then check whether GCC is installed on your system by entering the following command from the command line −
$ gcc -v
如果你在自己的机器上安装了 GNU 编译器,则它应当打印如下消息:
If you have GNU compiler installed on your machine, then it should print a message such as the following −
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix = /usr .......
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)
如果未安装 GCC,则您将不得不使用 https://gcc.gnu.org/install/ 中提供的详细说明自己安装它。
If GCC is not installed, then you will have to install it yourself using the detailed instructions available at https://gcc.gnu.org/install/
本教程是基于 Linux 编写的,并且所有给定的示例都已在 Linux 系统的 Cent OS 版本中编译。
This tutorial has been written based on Linux and all the given examples have been compiled on Cent OS flavor of Linux system.
Installation on Mac OS
如果你使用 Mac OS X,获取 GCC 的最简单方法是从 Apple 网站下载 Xcode 开发环境,并遵循简单的安装说明。一旦设置了 Xcode,你将能够使用 GNU 编译器针对 C/C++。
If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple’s website and follow the simple installation instructions. Once you have Xcode setup, you will be able to use GNU compiler for C/C++.
Xcode 当前可从 developer.apple.com/technologies/tools/ 获取。
Xcode is currently available at developer.apple.com/technologies/tools/
Installation on Windows
要在 Windows 上安装 GCC,需要安装 MinGW。要安装 MinGW,请访问 MinGW 主页 www.mingw.org ,然后单击 MinGW 下载页面的链接。下载 MinGW 安装程序的最新版本,它应当命名为 MinGW-<版本>.exe。
To install GCC on Windows, you need to install MinGW. To install MinGW, go to the MinGW homepage, www.mingw.org, and follow the link to the MinGW download page. Download the latest version of the MinGW installation program, which should be named MinGW-<version>.exe.
安装 MinWG 时,您至少必须安装 gcc-core、gcc-g++、binutils 和 MinGW 运行时,但您可能希望安装更多。
While installing MinWG, at a minimum, you must install gcc-core, gcc-g++, binutils, and the MinGW runtime, but you may wish to install more.
将 MinGW 安装的 bin 子目录添加到您的 PATH 环境变量,以便您可以通过其简单名称在命令行中指定这些工具。
Add the bin subdirectory of your MinGW installation to your PATH environment variable, so that you can specify these tools on the command line by their simple names.
安装完成后,你将可以使用 Windows 命令行来运行 gcc、g++、ar、ranlib、dlltool 以及其他一些 GNU 工具。
When the installation is complete, you will be able to run gcc, g++, ar, ranlib, dlltool, and several other GNU tools from the Windows command line.