mirror of
https://github.com/luzhisheng/js_reverse.git
synced 2025-04-12 03:27:07 +08:00
c++ 案例代码
This commit is contained in:
parent
56c3fd2976
commit
f582268746
3
CMake构建/v1/CMakeLists.txt
Normal file
3
CMake构建/v1/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(test)
|
||||
add_executable(app add.cpp div.cpp mult.cpp main.cpp sub.cpp)
|
9
CMake构建/v1/add.cpp
Normal file
9
CMake构建/v1/add.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include "head.h"
|
||||
|
||||
const char* libVersion = "Library Version 1.0";
|
||||
|
||||
int add(int a, int b)
|
||||
{
|
||||
return a+b;
|
||||
}
|
7
CMake构建/v1/div.cpp
Normal file
7
CMake构建/v1/div.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "head.h"
|
||||
|
||||
double divide(int a, int b)
|
||||
{
|
||||
return (double)a/b;
|
||||
}
|
11
CMake构建/v1/head.h
Normal file
11
CMake构建/v1/head.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _HEAD_H
|
||||
#define _HEAD_H
|
||||
|
||||
int add(int a, int b);
|
||||
|
||||
int subtract(int a, int b);
|
||||
|
||||
double divide(int a, int b);
|
||||
|
||||
int multiply(int a, int b);
|
||||
#endif
|
14
CMake构建/v1/main.cpp
Normal file
14
CMake构建/v1/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
#include "head.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
int a = 20;
|
||||
int b = 12;
|
||||
printf("a = %d, b = %d\n", a, b);
|
||||
printf("a + b = %d\n", add(a, b));
|
||||
printf("a - b = %d\n", subtract(a, b));
|
||||
printf("a * b = %d\n", multiply(a, b));
|
||||
printf("a / b = %f\n", divide(a, b));
|
||||
return 0;
|
||||
}
|
7
CMake构建/v1/mult.cpp
Normal file
7
CMake构建/v1/mult.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "head.h"
|
||||
|
||||
int multiply(int a, int b)
|
||||
{
|
||||
return a*b;
|
||||
}
|
7
CMake构建/v1/sub.cpp
Normal file
7
CMake构建/v1/sub.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "head.h"
|
||||
|
||||
int subtract(int a, int b)
|
||||
{
|
||||
return a-b;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user