易截截图软件、单文件、免安装、纯绿色、仅160KB

C程序:使用 googletest 测试框架

googletest C/C++ 测试框架非常好用,介绍及下载请看  http://code.google.com/p/googletest/
//============================================================================
// 使用 googletest 测试框架
//============================================================================

// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
int Factorial(int n)
{
int result = 1;
for (int i = 1; i <= n; i++)
{
result *= i;
}

return result;
}

#include "src/gtest-all.cc"

// Tests Factorial().
// Tests factorial of negative numbers.
TEST(FactorialTest, Negative)
{
EXPECT_EQ(1, Factorial(-5));
EXPECT_EQ(1, Factorial(-1));
EXPECT_TRUE(Factorial(-10)> 0);
}

// Tests factorial of 0.
TEST(FactorialTest, Zero)
{
EXPECT_EQ(1, Factorial(0));
}

// Tests factorial of positive numbers.
TEST(FactorialTest, Positive)
{
EXPECT_EQ(1, Factorial(1));
EXPECT_EQ(2, Factorial(2));
EXPECT_EQ(6, Factorial(3));
EXPECT_EQ(40320, Factorial(8));
}

#include "src/gtest_main.cc"


相关文档:

C bomb。。。。FML~~~

输出斐波那契数列前N个合数,四个一行,N由使用者输入,介于10到30之间。
#include<stdio.h>
#include<math.h>
int fab(int);
int judge(int);
int main()
{
int a[30]={0};
int i,n,t=0;
do
{
printf("Input the number\n");
scanf("%d",&n);
}
while(n>3 ......

C3P0数据源 连接Access数据库


<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.spri ......

C/C++中动态链接库的创建和调用

转自:http://dev.yesky.com/12/3067012.shtml
动态连接库的创建步骤:
  一、创建Non-MFC DLL动态链接库
  1、打开File —> New —> Project选项,选择Win32 Dynamic-Link Library —>sample project
  —>工程名:DllDemo
  2、新建一个.h文件DllDemo.h
以下是引用片段: ......

win7上的c和asm互调用

    最近在研究操作系统,《自己动手写操作系统》上第5章讲了asm和c函数之间互调用,目的是使用c来写操作系统内核的代码,毕竟用汇编写代码还是很费时间的事。
    配置Linux开发环境实在是太麻烦,要装虚拟机,还要配置老半天。于是就想能都在windows环境下实现互调用,很自然的想到了ming ......

汉诺塔算法的递归与非递归的C以及C++源代码



汉诺塔算法的递归与非递归的C以及C++源代码
By Minidxer | January 30, 2008
汉诺塔(又称河内塔)问题其实是印度的一个古老的传说。
开天辟地的神勃拉玛(和中国的盘古差不多的神吧)在一个庙里留下了三根金刚石的棒,第一根上面套着64个圆的金片,最大的一个在底下,其余一个比一个小,依次叠上 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号