由于论文需要,要对一些基本的操作进行运行时间的比较,用c语言比较合适,所以一下为用vs2015编写c语言的步骤。
首先,打开vs2015,选择 新建项目
然后出现新建项目的界面,选择VC++的编写环境,点击确定。
点击下一步
选择空项目
项目已经建好,右击源文件添加新建项。
并且命名为.c后缀
编好之后,注意按ctrl+F5,否则会出现程序框“一闪而过”的情形。
如果要计算程序运行时间,
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
clock_t begin, end;
double cost;
//开始记录
begin = clock();
/*待测试程序段*/
printf("hello world!\n");
//结束记录
end = clock();
cost = (double)(end - begin)/CLOCKS_PER_SEC;
printf("constant CLOCKS_PER_SEC is: %ld, time cost is: %lf secs", CLOCKS_PER_SEC, cost);
}